Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Need Help

Author  Topic 

julius.delorino
Starting Member

29 Posts

Posted - 2012-06-07 : 08:05:31
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
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-07 : 08:15:32
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

29 Posts

Posted - 2012-06-07 : 08:22:37
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
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-07 : 08:36:02
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
   

- Advertisement -