读书人

各位帮帮忙啊SQL存储过程 @@rowcount使

发布时间: 2012-01-14 20:02:35 作者: rapoo

各位帮帮忙啊~~SQL存储过程 @@rowcount使用
以下是存储过程中的一段:
--创建临时表
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

读书人网 >SQL Server

热点推荐