首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

各位帮帮忙啊SQL存储过程 @@rowcount使用解决思路

2012-01-14 
各位帮帮忙啊~~SQL存储过程 @@rowcount使用以下是存储过程中的一段:--创建临时表createtable#t(IDintIDENT

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

热点排行