Created
April 30, 2022 13:54
-
-
Save YPermitin/0cf089f565b298e0efcd7f153bd44fec to your computer and use it in GitHub Desktop.
Пример курсора для SQL Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Вывод списка пользовательских таблиц в базе данных | |
*/ | |
DECLARE @tableName sysname; | |
DECLARE tables_cursor CURSOR | |
FOR SELECT | |
[name] | |
FROM SYSOBJECTS | |
WHERE xtype = 'U'; | |
OPEN tables_cursor; | |
FETCH NEXT FROM tables_cursor INTO @tableName; | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
PRINT @tableName; | |
FETCH NEXT FROM tables_cursor INTO @tableName; | |
END | |
CLOSE tables_cursor; | |
DEALLOCATE tables_cursor; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment