首页 > 代码库 > SQL Server带游标的SQL

SQL Server带游标的SQL

DECLARE test_cursor CURSORFOR    SELECT  ID    FROM    dbo.T_BD_Restaurant    WHERE   id <> ‘0AAB2E55-79F8-4F41-AFFA-00179DFABDB0‘OPEN test_cursorDECLARE @RestaurantID NVARCHAR(100)FETCH NEXT FROM test_cursor INTO @RestaurantIDWHILE @@FETCH_STATUS = 0     BEGIN        PRINT @RestaurantID        FETCH NEXT FROM test_cursor INTO @RestaurantID    ENDCLOSE test_cursorDEALLOCATE test_cursor