What is a Stored Procedure?
A Stored Procedure is a group of logical SQL statements to perform a specific task, such as insert, select, update and delete operations on a table and so on which is stored in a SQL database.
. There are two ways to create procedure
- Using wizard
- Using create keyword
- Login into your SQL Server management studio
- Expand Databases option
- After expanding the databases option select the specific database in which you wants to create stored procedure .
- After expanding the specific database find sub folder Stored procedure under Programmability folder .
- Now right click on Stored procedure folder and click on New stored procedure as shown in below
After clicking on New stored procedure option then some default code will be generated ,modify that default code as your need and create procedure.
Using create keyword
Use the following code to create stored procedure using create keyword
Create Procedure AddEmployee ( --variable declareations @id int=null, @Fname Varchar (50)=null, @MName Varchar (50)=null, @Lname Varchar (50)=null ) as Begin Insert Into employee (FirstName,MName,LastName)values(@Fname,@MName,@Lname) EndWatch Video
I hope this article is useful for all readers..if you have any suggestion related to this article then please contact me.