declare @tid int       
declare @fid int
declare @i int
declare @j int
set @j=(select count(*) from tbl1.dbo.dnt_topics)
set @i=1        
while   @i<@j        
begin            
    set @tid = (select tid from ( select ROW_NUMBER() over (order by tid asc ) as Row, tid,fid from dnt_topics ) as sp  where Row=@i)
    set @fid=(select fid from ( select ROW_NUMBER() over (order by tid asc ) as Row, tid,,fid from dnt_topics ) as sp  where Row=@i)                
    update            
        tbl2.dbo.dnt_topics         
    set                 
        fid=@fid        
    where             
        tid=@tid                    
        set @i=@i+1        
end
posted on 2013-09-23 09:21  swarb  阅读(315)  评论(0编辑  收藏  举报