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 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 PersonalDetails SET FirstName = @FirstName, LastName = @LastName, Age = @Age, Active = @Active WHERE PersonalDetailsId = @PersonalDetailsId END
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: 9151 | Post Order: 90