SQL Server带游标的SQL

DECLARE test_cursor CURSOR
FOR
    SELECT  ID
    FROM    dbo.T_BD_Restaurant
    WHERE   id <> '0AAB2E55-79F8-4F41-AFFA-00179DFABDB0'

OPEN test_cursor

DECLARE @RestaurantID NVARCHAR(100)

FETCH NEXT FROM test_cursor INTO @RestaurantID
WHILE @@FETCH_STATUS = 0 
    BEGIN

        PRINT @RestaurantID

        FETCH NEXT FROM test_cursor INTO @RestaurantID

    END
CLOSE test_cursor
DEALLOCATE test_cursor

  

posted @ 2014-07-23 16:25  kevin_h_wang  阅读(192)  评论(0编辑  收藏  举报