SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Need Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

julius.delorino
Starting Member

Philippines
29 Posts

Posted - 06/07/2012 :  08:05:31  Show Profile  Reply with Quote
sir i have this problem on how to write this effectively on stored procedure;

Declare @Param1 nvarchar(10),@Param2 nvarchar(20),@Param3 int OUTPUT
set Param3 =0

if(
select var1,var2 from table where var1=@param1 and var2 =@param2)
set @param3 =1
else
Set @Param3 =0

how can you write this on a stored procedure,i hope you can help me guys thank i advance,more power SQLTEAM.

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 06/07/2012 :  08:15:32  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
create proc x
@Param1 nvarchar(10),@Param2 nvarchar(20),@Param3 int OUTPUT
as
if exists (select * from table where var1=@param1 and var2 =@param2)
select @param3 =1
else
select @Param3 =0
go



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

julius.delorino
Starting Member

Philippines
29 Posts

Posted - 06/07/2012 :  08:22:37  Show Profile  Reply with Quote
thanks for your reply, but not the output that i wanted,but thanks anyway. i am writing a simple login script in which i will pass
2 parameters from vb.net then the stored procedure will process
if the parameters passed is equal to the selected data from table,
if equal then return 1 else return 0. that kind of logic in writing
stored procedure what i am looking for,but thanks for your help sir.
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 06/07/2012 :  08:36:02  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
That takes the two parameters. If there is a row in the table that matches it returns 1 else 0.
That's sounds like what you want?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000