Sql Server存储过程中如何调用存储过程接收输出参数返回值
更新:HHH   时间:2023-1-7


这篇文章将为大家详细讲解有关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存储过程中如何调用存储过程接收输出参数返回值就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

返回数据库教程...