在存储过程中定义一个输出变量:
create table tablename(
A varchar(1000)
)
insert into tablename values(',c,d,d,e,c,f,')create procedure pr_get
@str varchar(100),
@row int output
as
select * from tablename
select @row=@@rowcount
go
declare @row int
execute pr_get 'c',@row output
select @row
create table tablename(
A varchar(1000)
)
insert into tablename values(',c,d,d,e,c,f,')create procedure pr_get
@str varchar(100),
@row int output
as
select * from tablename
select @row=@@rowcount
go
declare @row int
execute pr_get 'c',@row output
select @row
GO
SET ANSI_NULLS OFF
GO
CREATE PROCEDURE [dbo].[SelectTest_count]
@Count int Output AS
select * from test
set @Count=(select @@rowcount)GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO--测试
declare @out int
exec SelectTest_count @out Output --加上output
select @out
在结果集中用getUpdateCount()就可以取到
select @@rowcount
GO
SET ANSI_NULLS OFF
GO
CREATE PROCEDURE [dbo].[SelectTest_count]
select * from test
return @@rowcountGO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GOdeclare @rc int
exec @rc = SelectTest_count
select @rc