T-SQL: Stored Procedures (DELETE), DELETE An Existing Northwind Product Part 3

To create the delete procedure type in the following code in the SQL editor window in "Microsoft SQL Server Management Studio"

USE Northwind
GO
CREATE PROCEDURE dbo.delProduct @ProductID int
AS
DELETE FROM Products
WHERE Products.ProductID = @ProductID
GO

The stored procedure only takes in one input parameter which is the ProductID, the DELETE statement needs a ProductID because if there is no WHERE clause, every record in the product in the Products table will be deleted. Make sure you backup the table before you work with a DELETE stored procedure.
Here is how would execute the stored procedure
EXEC dbo.delProduct 78


Blogs In the T-SQL Series:

Comments

Popular posts from this blog

Docker : Adding Docker Repository Key and Updating Docker To The Latest Version

ASP.NET Core : Add jQuery, Bootstrap, AngularJS Using bower.json

Install the Northwind Sample Database