SQL Server > Stored Procedure

Execute a stored procedure from query window in SQL Server

How to execute a stored procedure from the query window in SQL Server?


To execute a stored procedure from the query window, we can use EXEC statements.

Executing parameter less stored procedure is very simple, use EXEC with stored procedure name.

-- Execute parameter less Stored procedure
EXEC GetAllPersonalDetails

Notice that the database dropdown must have the database selected in which the stored procedure exists.

Executing stored procedure with parameter is just passing the parameter value followed by the name of the stored procedure.

-- Execute Stored procedure with parameter
EXEC LoadPersonalDetails 10

As this stored procedure, created above takes Age as parameter, we have passed its value as 10 that returns all records from the PersonalDetials table having age more than 10. If we have more than one parameter in the stored procedure, we pass those parameters values separated by comma.

 Views: 50725 | Post Order: 88



Write for us






Hosting Recommendations