mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -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"
|
"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": {
|
"Show space used by tables": {
|
||||||
"prefix": "sqlGetSpaceUsed",
|
"prefix": "sqlGetSpaceUsed",
|
||||||
"body": [
|
"body": [
|
||||||
|
|||||||
Reference in New Issue
Block a user