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

时间:2022-08-29 14:06:56

创建存储过程:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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

接收输出参数:

?
1
2
3
DECLARE @count INT
EXECUTE GetCustomers @count OUTPUT
PRINT @count

2,带返回值

创建存储过程:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
ALTER PROCEDURE [dbo].[GetCustomers]
AS
  SELECT [CustomerID]
   ,[CompanyName]
   ,[ContactName]
   ,[ContactTitle]
   ,[Address]
   ,[City]
   ,[Region]
   ,[PostalCode]
   ,[Country]
   ,[Phone]
   ,[Fax]
 FROM [Northwind].[dbo].[Customers]
RETURN @@rowcount

接收返回值:

?
1
2
3
DECLARE @count INT
EXECUTE @count=GetCustomers 
PRINT @count

以上所述是小编给大家介绍的Sql Server 存储过程调用存储过程接收输出参数返回值,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!

原文链接:http://blog.csdn.net/lifewinnerforever/article/details/72841195