SQL Server: Stored Procedure for update with optional parameters

3 Comments | 822 Views | Post by: Admin | Tags: Stored Procedure for update with optional parameters


SQL Server: Stored Procedure for update with optional parameters


CREATE PROCEDURE [dbo].[UpdtEmployee]
(
    @EmpId INT,
    @EmpName VARCHAR(100)=NULL,
    @Address VARCHAR(200)=NULL,
    @EmpPhotoPath VARCHAR(100)=NULL,
    @MobileNo VARCHAR(14)=NULL
)
AS
BEGIN
    UPDATE dbo.Employee
    SET EmpName=ISNULL(@EmpName,EmpName),
        Address=ISNULL(@Address,Address),
        EmpPhotoPath=ISNULL(@EmpPhotoPath,EmpPhotoPath),
        MobileNo=ISNULL(@MobileNo,MobileNo)
    WHERE EmpId=@EmpId
END

 


Post Comments

if you have some suggestion, question, request on SQL Server: Stored Procedure for update with optional parameters.

Please use the comment box to express your views.

 

Comments:

loading...