mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Add cursor snippet (#475)
* Add cursor snippet * Workaround to avoid issue #480 Remove SELECT and tab to the place for custom code
This commit is contained in:
committed by
Karl Burtram
parent
b73b09a1d3
commit
e4a0e4e0c1
@@ -243,6 +243,33 @@
|
||||
"description": "Lists all the columns and their types for tables matching a LIKE statement"
|
||||
},
|
||||
|
||||
"Declare a cursor": {
|
||||
"prefix": "sqlCursor",
|
||||
"body": [
|
||||
"-- Declare a cursor for a Table or a View '${1:TableOrViewName}' in schema '${2:SchemaName}'",
|
||||
"DECLARE @Column1 NVARCHAR(50), @Column2 NVARCHAR(50)",
|
||||
"",
|
||||
"DECLARE db_cursor CURSOR FOR",
|
||||
"SELECT Column1, Column2",
|
||||
"FROM $2.$1",
|
||||
"",
|
||||
"OPEN db_cursor",
|
||||
"FETCH NEXT FROM db_cursor INTO @Column1, @Column2",
|
||||
"",
|
||||
"WHILE @@FETCH_STATUS = 0",
|
||||
"BEGIN",
|
||||
"\t-- add instructions to be executed for every row",
|
||||
"\t$3",
|
||||
"\tFETCH NEXT FROM db_cursor INTO @Column1, @Column2",
|
||||
"END",
|
||||
"",
|
||||
"CLOSE db_cursor",
|
||||
"DEALLOCATE db_cursor",
|
||||
"GO"
|
||||
],
|
||||
"description": "Declare a cursor"
|
||||
},
|
||||
|
||||
"Show space used by tables": {
|
||||
"prefix": "sqlGetSpaceUsed",
|
||||
"body": [
|
||||
|
||||
Reference in New Issue
Block a user