A stored procedure defines SQL statements that can be run on command. Stored procedures are used to encapsulate programmatic logic in a database for actions that applications need to perform when working with data. You can define a stored procedure with parameters to create a flexible solution for common actions that might need to be applied to data based on a specific key or criteria. For example, the following stored procedure could be defined to change the name of a product based on the specified product ID. SQL Copy CREATE PROCEDURE RenameProduct @ProductID INT, @NewName VARCHAR(20) AS UPDATE Product SET Name = @NewName WHERE ID = @ProductID; When a product must be renamed, you can execute the stored procedure, passing the ID of the product and the new name to be assigned: SQL Copy EXEC RenameProduct 201, 'Spanner';
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.