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