⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cursordemo12.sql

📁 T-SQL示例大全
💻 SQL
字号:
/* 文件名称:  CursorDemo12.sql */
USE pubs
GO
-- Create and open a global named cursor that
-- is visible outside the batch.
DECLARE abc CURSOR GLOBAL SCROLL FOR
SELECT * FROM authors

OPEN abc
GO

-- Reference the named cursor with a cursor variable.
DECLARE @MyCrsrRef1 CURSOR

SET @MyCrsrRef1 = abc

-- Now deallocate the cursor reference.
DEALLOCATE @MyCrsrRef1

-- Cursor abc still exists.
FETCH NEXT FROM abc
GO

-- Reference the named cursor again.
DECLARE @MyCrsrRef2 CURSOR

SET @MyCrsrRef2 = abc

-- Now deallocate cursor name abc.
DEALLOCATE abc

-- Cursor still exists, referenced by @MyCrsrRef2.
FETCH NEXT FROM @MyCrsrRef2

-- Cursor finally is deallocated when last referencing
-- variable goes out of scope at the end of the batch.
GO

-- Create an unnamed cursor.
DECLARE @MyCursor CURSOR

SET @MyCursor = CURSOR LOCAL SCROLL FOR
SELECT * FROM titles

-- The following statement deallocates the cursor
-- because no other variables reference it.
DEALLOCATE @MyCursor
GO



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -