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)来实现

相关文章:

  • 2021-11-28
  • 2021-11-13
  • 2021-05-23
  • 2021-07-03
  • 2021-12-07
  • 2021-07-06
  • 2022-12-23
  • 2021-11-23
猜你喜欢
  • 2021-10-21
  • 2021-10-10
  • 2022-12-23
  • 2021-11-23
  • 2022-03-05
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案