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

1,带输出参数

创建存储过程:

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,存储,output)