Updated on Kisan Patel
This tutorial will show you 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 UpdateRegionDetails -- Add the parameters for the stored procedure here @RegionId int, @RegionDesription varchar(50), @Age smallint AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here UPDATE Region set RegionDescription=@RegionDesription ,AGE=@Age Where RegionID = @RegionId END
Notice the above stored procedure code, this is almost similar to the Insert stored procedure. We have just added a new parameter named “RegionID” that is being used in the WHERE clause of the UPDATE statement.
Calling the stored procedure is same as calling INSERT stored procedure.