checking if condition in stored procedure( sql server 2005) -
i have sp need check if condition
alter procedure [dbo].[spcheck] @strempname varchar(50), @intreturn int output, @intworkdid int, @intempid int begin if(@intworkdid not null , @intworkdid != '') begin if exists ( select * employee [empname] = @strempname , workid = @intworkdid ) select @intreturn = '1' end else if(@intempid not null , @intempid != '') begin if exists ( select * employee [empname] = @strempname , peopleid = @intempid ) select @intreturn = '1' end else if(@intempid not null , @intempid != '') and(@intworkdid not null , @intworkdid != '') begin select @intreturn = '0' end end
here based on workid,empid
1 condition , 2 condition should execute
if both condition fail need excute third condition
can 1 tell syntax
thanks
prince
best way can use
try below:
select @intreturn = case when @intworkdid null 1 when @intworkdid<>'' 1 when @intempid null 1 when @intempid <>'' 1 else 0 end
for
Comments
Post a Comment