declare @count int 
declare @total int                        --记录总数
declare @maxID int                        --最大id记录
declare @tmp_Id int
declare @tmp_memberId  varchar(36)        --用户Id  
declare @tmp_userCode  varchar(60)        --用户名
set @count=1
select  @total=count(*) from waydu..T_mem_memberInfo
select @maxID=max(id) from  waydu..T_mem_memberInfo
   while(@count<=@total)
      begin
         set @count=@count+1
         select @tmp_Id=max(id) from  waydu..T_mem_memberInfo where id<isnull(@tmp_Id,@maxID+1)
         select @tmp_memberId=memberId,@tmp_userCode=userCode from  waydu..T_mem_memberInfo where id=@tmp_Id
         --插入记录:
         insert into T_mem_memberInfo(memberId,userCode,passWord,nickName,Email,question,answer,isAllow,isOnline,regTime,lastTime,changeTime,intergral,fortuneGlory,scholarGlory,isFine,private,Company,CompanyType,Trade,Career,Contact,IsApproved,QqMsn,Blog,age,iscommend)
         select memberId,userCode,passWord,nickName,Email,question,answer,isAllow,isOnline,regTime,lastTime,changeTime,intergral,fortuneGlory,scholarGlory,isFine,private,Company,CompanyType,Trade,Career,Contact,IsApproved,QqMsn,Blog,age,'0' from waydu..T_mem_memberInfo where id=@tmp_Id
      end

========================================================================================

其实上述功能也可用游标(cursor)来实现

posted on 2009-05-31 11:31  钱途无梁  阅读(605)  评论(0编辑  收藏  举报