Skip to content

Instantly share code, notes, and snippets.

@alevyinroc
Created July 6, 2018 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alevyinroc/11338a940308fbe1a4eadabbd28e153b to your computer and use it in GitHub Desktop.
Save alevyinroc/11338a940308fbe1a4eadabbd28e153b to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<_locDefinition xmlns="urn:locstudio">
<_locDefault _loc="locNone" />
<_locTag _loc="locData">Title</_locTag>
<_locTag _loc="locData">Description</_locTag>
<_locTag _loc="locData">Author</_locTag>
<_locTag _loc="locData">ToolTip</_locTag>
</_locDefinition>
<CodeSnippet Format="1.0.0">
<Header>
<Title>Cursor</Title>
<Shortcut></Shortcut>
<Description>Code Snippet for T-SQL Cursor</Description>
<Author>Andy Levy</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal><ID>LoopVar</ID></Literal>
<Literal><ID>CursorName</ID></Literal>
<Literal><ID>TypeName</ID></Literal>
</Declarations>
<Code Language="SQL"><![CDATA[
DECLARE @$LoopVar$ AS $TypeName$;
DECLARE @$CursorName$ as CURSOR;
SET @$CursorName$ = CURSOR FOR
$QueryToLoop$;
OPEN @$CursorName$;
FETCH NEXT FROM @$CursorName$ INTO @$LoopVar$;
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM @$CursorName$ INTO @$LoopVar$;
END;
CLOSE @$CursorName$;
DEALLOCATE @$CursorName$;
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment