Sql Server 存储过程调用存储过程接收输出参数返回值

创建存储过程:

ALTER PROCEDURE [dbo].[GetCustomers]
(@rowcount INT OUTPUT)
AS
SELECT [CustomerID]
,[CompanyName]
,[ContactName]
,[ContactTitle]
,[Address]
,[City]
,[Region]
,[PostalCode]
,[Country]
,[Phone]
,[Fax]
FROM [Northwind].[dbo].[Customers]
SET @rowcount=@@rowcount

接收输出参数:

DECLARE @count INT
EXECUTE GetCustomers @count OUTPUT
PRINT @count

2,带返回值

创建存储过程:

ALTER PROCEDURE [dbo].[GetCustomers]
AS
SELECT [CustomerID]
,[CompanyName]
,[ContactName]
,[ContactTitle]
,[Address]
,[City]
,[Region]
,[PostalCode]
,[Country]
,[Phone]
,[Fax]
FROM [Northwind].[dbo].[Customers]
RETURN @@rowcount

接收返回值:

DECLARE @count INT
EXECUTE @count=GetCustomers
PRINT @count

以上所述是小编给大家介绍的Sql Server 存储过程调用存储过程接收输出参数返回值,大家如有疑问可以留言,或者联系站长。感谢亲们支持!!!


数据运维技术 » Sql Server 存储过程调用存储过程接收输出参数返回值