-- Simple store procedure just return result set, accepts no input at all, perform no input validation
CREATE PROCEDURE dbo.GetProducts
AS
SELECT * FROM dbo.Products
-- Simple store procedure return result set, accepts user input or parameter
CREATE PROCEDURE dbo.GetProducts
-- parameter section or user input section
@productName VARCHAR(50)
AS
SELECT * FROM dbo.Products
WHERE ProductName = @productName
-- parameter section or user input section
@productName VARCHAR(50)
AS
SELECT * FROM dbo.Products
WHERE ProductName = @productName
To Do...
- Multiple parameters
- Require and optional parameters
- Parameters validation
- Conditional execution
- Transaction in store procedure
- And more…
No comments:
Post a Comment