SQL Server > Stored Procedure

update record stored procedure in SQL Server

How to create stored procedure to update record in the SQL Server database?

To write Update stored procedure, follow the same procedure, simply write UPDATE sql statement inside the stored procedure.

CREATE PROCEDURE UpdatePersonalDetails
       -- Add the parameters for the stored procedure here
       @PersonalDetailsId int,
       @FirstName varchar(50),
       @LastName varchar(50),
       @Age smallint,
       @Active bit
       -- SET NOCOUNT ON added to prevent extra result sets from
       -- interfering with SELECT statements.

    -- Insert statements for procedure here
       UPDATE PersonalDetails SET FirstName = @FirstName, LastName = @LastName,
              Age = @Age, Active = @Active WHERE PersonalDetailsId =

Notice the above stored procedure code, this is almost similar to the Insert stored procedure. We have just added a new parameter named “PersonalDetailsId” that is being used in the WHERE clause of the UPDATE statement.

Calling the stored procedure is same as calling INSERT stored procedure we saw ealier.

 Views: 52946 | Post Order: 90

Write for us

Hosting Recommendations