Execute a stored procedure in Microsoft SQL Server

Syntax of Execute stored procedure in MSSQL Server

Execute the Stored Procedure with exec command:

Taking an example of stored procedure as follows:

Syntax of Procedure: ALTER PROCEDURE [dbo].[uspGetEmployeeManagers] @BusinessEntityID [int]

Pass parameter direct with comma seperated or use can give the parameter name with @ and specify its value.

--Example of different ways:
EXEC [dbo].[uspGetEmployeeManagers] 3455

OR

USE [AdventureWorks2017]
GO
DECLARE              @return_value int
EXEC      @return_value = [dbo].[uspGetEmployeeManagers] 3455
SELECT  'Return Value' = @return_value

OR

EXEC  [dbo].[uspGetManagerEmployees] @BusinessEntityID = 3455

OR

DECLARE              @return_value int
EXEC      @return_value = [dbo].[uspGetWhereUsedProductID]                                @StartProductID = NULL,
@CheckDate = NULL
SELECT  'Return Value' = @return_value
This entry was posted in Oracle on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply