In this blog, I will show step by step how to create a Stored Procedure in SQL Server. explain how its works and why we need to do this. Let’s Go.
I. Microsoft SQL Server
Microsoft SQL Server is a relational database management system developed by Microsoft. As a database server, it is a software product with the primary function of storing and retrieving data as requested by other software applications which may run either on the same computer or on another computer across a network.
II. Stored Procedure
A stored procedure is a set of Structured Query Language (SQL) statements with an assigned name, which are stored in a relational database management system (RDBMS) as a group, so it can be reused and shared by multiple programs.
A stored procedure is a subroutine available to applications that access a relational database management system. Such procedures are stored in the database data dictionary. Uses for stored procedures include data-validation or access-control mechanisms.
To download MS SQL Server, click Here
III. Requirements
- Microsoft SQL Server
Download and Install SQL Server Management Studio to proceed this tutorial.
IV. Connect SQL Server
First connect the server, I’ll use my local DB and use windows Authentication. then Connect.
This is the view after connect is suceed.
Click Databases to open the list of databases. And now I use the old sample which is the create previous tutorial/blog about: How to create databases and tables in SQL
This is the sample table inside the testDB database. there is users table and user_genter table.
USER TABLE:
USER_GENDER TABLE:
V. Create Store Procedure
Please follow the steps. TestDB -> Programmability -> Stored Procedures.
Right click the Stored Procedures and click the Stored Procedures…
this is the default script after clicking.
- this is the name of the strode procedure and you need to replace it whatever you like it. but for me I named it SP_getUsers.
- this is the parameter, incase if you need parameter in your query, but in this case we don’t need it. so I remove that.
- This is the important part of the script. the query statement.
- the work “Create” replace “Alter” After created.
This is what look like.
And you can refresh and see the created Store Procedures
Related Topics
Import SQL Database in SSMS from Local Machine
In this article, We learn how to Import SQL Database in SSMS in Local Machine. I will show how to do it, and just follow […]
Export(Backup) SQL Database in SSMS in Local Machine
In this article, We learn how to export(Backup) SQL Database in SSMS in Local Machine. I will show how to do it, and just follow […]
Angular CRUD with .NET Core API
In this article, We create a full tutorial of Angular CRUD with .NET Core API. I will show how to do it, and just follow […]
Create Table in MSSQL using T-SQL Command/Statement
In this blog, I will show how to create Table in MS SQL using T-SQL command. explain how its works and why we need to […]
Use UNION Operator in SQL
In this blog, I will show how to use and where to use UNION in SQL. Explain How its work and why we need to use […]
I抎 need to check with you here. Which isn’t one thing I normally do! I take pleasure in studying a publish that can make people think. Additionally, thanks for permitting me to comment!