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:
Sebastian Pfliegel
2018-01-12 21:39:17 +01:00
committed by Karl Burtram
parent b73b09a1d3
commit e4a0e4e0c1

View File

@@ -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": [