Stored Procedure in SQL

This article I will give you some basic syntax about stored procedure in SQL.

Image for post
Image for post

Stored Procedure:

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.

Written by

A current Data Analyst in a subsidiary under Webjet, with experience in applying data science techniques to business.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store