--定義Cursor
DECLARE MyCursor Cursor FOR
SELECT [FieldTypeName] FROM [CRM_Test].[dbo].[FieldType]
--開啟Cursor
Open MyCursor
--定義接收變數
DECLARE @FieldTypeName nvarchar(50)
--迴圈跑Cursor
Fetch NEXT FROM MyCursor INTO @FieldTypeName
While (@@FETCH_STATUS = 0)
BEGIN
print @FieldTypeName
Fetch NEXT FROM MyCursor INTO @FieldTypeName
END
--關閉及釋放cursor
CLOSE MyCursor
DEALLOCATE MyCursor
沒有留言:
張貼留言