复制代码 代码如下:
DECLARE @OldId varchar(50)  
DECLARE @CustomerID varchar(50)  
DECLARE My_Cursor CURSOR --定义游标  
FOR (select CustomerID,oldid from Customer where Area='bj') --查出需要的集合放到游标中  
OPEN My_Cursor; --打开游标  
FETCH NEXT FROM My_Cursor INTO @CustomerID,@OldId; --读取第一行数据  
WHILE @@FETCH_STATUS = 0     
    BEGIN    
       DECLARE @OtherPro VARCHAR(500)  
       DECLARE @StatusID varchar(200)  
       DECLARE @Userid varchar(200)  
       DECLARE @FinalUserid varchar(200)  

      SELECT @OtherPro=OtherPro,@StatusID=CustomerStatusID,@Userid=UserID FROM bjsunmis.dbo.Customer WHERE CustomerID=@OldId;  

      SELECT @FinalUserid=UserID from Users where oldid=@Userid  

      INSERT INTO CustomerotherInfo(CustomerID,OtherPro,CustomerStatusID,UserID)VALUES(@CustomerID,@OtherPro,@StatusID,@FinalUserid)  

     FETCH NEXT FROM My_Cursor INTO @CustomerID,@OldId; --读取下一行数据      
    END 
CLOSE My_Cursor; --关闭游标  
DEALLOCATE My_Cursor; --释放游标  
GO

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com