游标示例

DECLARE My_Cursor CURSOR FOR  
    SELECT CellID,TableName FROM [dbo].[tblUpdateInfo]
    OPEN My_Cursor;  
    DECLARE @CellID char(2)
    DECLARE @TableName varchar(50)
    FETCH NEXT FROM My_Cursor INTO @CellID,@TableName;  
    WHILE @@FETCH_STATUS = 0  
       BEGIN  
          PRINT @CellID
          PRINT @TableName
        
          FETCH NEXT FROM My_Cursor INTO @CellID,@TableName;  
       END;  
    CLOSE My_Cursor;  
    DEALLOCATE My_Cursor;
posted @ 2017-06-07 20:18  Paddy138  阅读(188)  评论(0编辑  收藏  举报