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
- 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.
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
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 […]
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 […]
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 […]
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 […]