How to create a stored procedure?

949    Asked by ElizabethClarke in SQL Server , Asked on Jan 8, 2020
Answered by Rachit Gupta

Store procedure can be created by mainly 2 ways:

Using SQL commands:

1. Connect to server


2. Connect to the database


3. The syntax for the Stored Procedure.

Use [databasename]

Go

Create procedure Schema_Name].[Procedure_Name]

(

@parameter1 Datatype ,

@parameter2 Datatype)

as

Begin

--SQL statements

End

( using F5/ execute button)


The procedure can also be created by GUI interface on the server:

1. Connect to server

2. Connect to the database

3. Click on the database and expand--> Click on Programmability --> Right Click on stored Procedure --> Click on stored Procedure


you will get the script of the procedure on the text editor

4. Fill the field/ Parameter details in the syntax.



Your Answer

Interviews

Parent Categories