SQL存储过程 @@rowcount使用

来源:百度知道 编辑:UC知道 时间:2024/06/07 06:01:29
以下是存储过程中的一段:
--创建临时表
create table #t (ID int IDENTITY, --自增字段
yhm_id int,
yhm_name varchar(40))
--向临时表中写入数据
insert into #t
select yhm_id,yhm_name from dbo.[yhm]
order by yhm_id
--select * from dbo.[t]
--取得记录总数
declare @iRecordCount int
set @iRecordCount=@@rowcount
上面yhm表中有数据,而新创建的表中也有记录,但是@@rowcount返回的值总是零,也就是@iRecordCount的值也是零,怎么办啊,急~~
如果认为并不是这小段错误,请回复,给你完整

占位,回头回答!

create table #t (ID int IDENTITY, --自增字段
yhm_id int,
yhm_name varchar(40))
--向临时表中写入数据
declare @iRecordCount int
insert into #t
select yhm_id,yhm_name from dbo.[yhm]
order by yhm_id
--select * from dbo.[t]
--取得记录总数
set @iRecordCount=@@rowcount

这个试下!不行了!ME我

--源表
create table t1(name varchar(40))
insert into t1 select 'abc'
insert into t1 select 'def'
insert into t1 select 'ghi'

--创建临时表
create table #t (ID int IDENTITY, yhm_name varchar(40))

--向临时表中写入数据
insert into #t
select name from t1

select @@rowcount

--取得记录总数
declare @iRecordCount int

set @iRecordCount=@@rowcount

print @iRecordCount

--删除测试数据
drop table #t,t1

--结果
/*
3
*/

********************************************************
联机帮助:
@@RO