This article I will give you some basic syntax about stored procedure in SQL.
Stored Procedure is the prepared SQL codes that we can save, so the code can be reused over and over again.
It is suitable for some SQL queries we need to use frequently.
There are three kinds of stored procedure:
- No parameter
- One parameter
- multiple parameters
* Stored Procedure (No parameter) Syntax
CREATE PROCEDURE procedure_name AS sql_statement GO EXEC procedure_name
* Stored Procedure (One parameter) Syntax
CREATE PROCEDURE [dbo].[oneparameter] @ProductCatergoryID int AS SELECT *FROM Production.ProductCategoryID GO EXEC oneparameter @ProductCatergoryID = '4'
* Stored Procedure (multiparameter) Syntax
CREATE PROCEDURE [dbo].[multiparameter] @ProductCategoryID int, @Name varchar(50) AS SELECT *FROM Production.ProductCategory pc WHERE pc.ProductCategoryID = @ProductCategoryID and pc.Name = @Name GO EXEC multiparameter @ProductCategoryID = '4', @Name = 'Accessories'
I will record all knowledge I touch in my Business Intelligence journey.
Next blog will be around Data Warehouse.
If you are interested in or have any problems with Business Intelligence, feel free to contact me .
Or you can connect with me through my LinkedIn.
Originally published at http://jacquiwu.com on August 20, 2019.