创建存储过程:

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 存储过程调用存储过程接收输出参数返回值,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

02-05 14:20