Updated on Kisan Patel
This tutorial will show you 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 GetAllRegionDetails
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 LoadPRegionDetails 10
As this stored procedure, created above takes Age as parameter, we have passed its value as 10 that returns all records from the Region 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.