SQL Server: Stored Procedure for update with optional parameters

  MSSQLSERVER   Friday, October 30, 2015   1388 | No Comments Yet!!! | No Download | No Demo | Pawan kumar
 Tags: 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: