MSSQL CURSOR (指標) 筆記
DECLARE CURSOR_DATA CURSOR FOR SELECT RULENUMBER FROM RULES --建立指標
OPEN ABC --開啓指標
FETCH NEXT FROM CURSOR_DATA INTO @TMP --開始查詢
WHILE @@FETCH_STATUS=0 -- 判斷指標是否到結尾
BEGIN
PRINT @TMP --列印變數
FETCH NEXT FROM CURSOR_DATA
INTO @TMP
END
CLOSE CURSOR_DATA
DEALLOCATE CURSOR_DATA