i have an SP where i need to check for if condition
ALTER PROCEDURE [dbo].[spCheck]
@strEmpname VARCHAR(50),
@intReturn INT OUTPUT,
@intWorkdID INT,
@intEmpID INT
AS
BEGIN
IF(@intWorkdID is not null and @intWorkdID != '')
BEGIN
IF EXISTS ( SELECT *
FROM Employee
WHERE [Empname] = @strEmpname
AND WorkID = @intWorkdID
)
SELECT @intReturn = '1'
END
ELSE
IF(@intEmpID is not null and @intEmpID != '')
BEGIN
IF EXISTS ( SELECT *
FROM Employee
WHERE [Empname] = @strEmpname
AND PeopleID = @intEmpID
)
SELECT @intReturn = '1'
END
ELSE IF(@intEmpID is not null and @intEmpID != '')
and(@intWorkdID is not null and @intWorkdID != '')
BEGIN
SELECT @intReturn = '0'
END
END
here based on WorkID,EmpID
1 condition and 2 condition should execute
if both condition fail i need to excute the third condition
can any one tell the syntax for it
thanks
prince
Best way is that you can use
Try something as below:
Case… When
for this