1
Reply

How to check if variable is NULL In Stored Procedure?

    Create PROCEDURE [dbo].[UpdateRecord]
    (
       @empId int,
       @name varchar(200),
    )

    AS

    DECLARE
    @chkName varchar(200)

    SET @chkName=(SELECT TOP 1 Emp_Name FROM Employee WHERE EmpId=@empId )

    IF @chkName IS NULL

    BEGIN
       UPDATE Employee SET Emp_Name = @name WHERE EmpId = @empId
    END