日期:2014-05-18  浏览次数:20421 次

各位帮帮忙啊~~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