欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-08-20 21:29:08
创建存储过程: alter procedure [dbo].[getcustomers] (@rowcount int output) as s...

创建存储过程:

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 存储过程调用存储过程接收输出参数返回值,希望对大家有所帮助