SQL游标遍历数据表

DECLARE   @资产编号 VARCHAR(50) ,@gsid VARCHAR(50)   
DECLARE test_Cursor CURSOR LOCAL FOR
SELECT   资产编号,gsid FROM zctemp

OPEN test_Cursor
WHILE @@FETCH_STATUS = 0

    BEGIN  

        FETCH NEXT FROM test_Cursor INTO @资产编号,@gsid
        PRINT '--------------------------'+@资产编号      

    END 

CLOSE test_Cursor

DEALLOCATE test_Cursor

 

你可能感兴趣的:(SQL游标遍历数据表)