Posts Tagged ‘Create custom snippet for Sequence object’

SEQUENCE object is one of my favorite objects introduced in SQL Server 2012. It is very handy when you need an enhanced functionality in an identity column. Due to its performance & functionality, I use it very frequently, but the issue is, I either need to write the complete script of sequence by myself or I need to use SSMS and then go to database >> Programmability >> Sequence and create a new sequence object as shown in the picture below.

create sequence snippet.1.1

Alternatively, we can create the Sequence object snippet, as shown in the script below.  Just copy the given below script and save as “Create Sequence.snippet” and register it. Once registered, you can use it like any other custom snippet.

<?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>
	<CodeSnippet Format="1.0.0">
	<Title>Create Sequence</Title>
	<Description>Creates a sequence.</Description>
	<Author>Muhammad Imran</Author>
				<ToolTip>Name of the schema</ToolTip>
				<ToolTip>Name of the Sequence</ToolTip>
				<ToolTip>Data type of the column</ToolTip>
        <ToolTip>Start Value</ToolTip>
        <ToolTip>Increment Value</ToolTip>
        <ToolTip>Min Value</ToolTip>
        <ToolTip>Max Value</ToolTip>
        <ToolTip>Cache Value</ToolTip>
		<Code Language="SQL">
			<![CDATA[CREATE SEQUENCE [$SchemaName$].[$Sequencename$]
AS [$datatype$]
START WITH $start$
INCREMENT BY $increment$
MINVALUE $minvalue$
MAXVALUE $maxvalue$
CACHE $Cache$ 

Read Full Post »