New tsql commands in Sql Server 2012 (Part 1)

Next year there is a new Sql Server release. In my next posts i will write about some of the TSql commands that are new in Sql Server 2012 (Denali).

Today i will start with the command to create sequences. With the create sequence command it is possible to create a sequence of numbers with a startvalue and an increment value.

Selecting the sequence. Every time the next value for “SequenceName” is called the sequence gets incremented by the defined value.

Result of the selection.

The sequence has some additional keywords. The minvalue defines the minimum value of the sequence the maxvalue defines the maximum value of the sequence and the cycle keyword defines that the sequence reuses the values. That means that if the sequence reaches his maxvalue the sequence count starts at the begining. The following sequence uses the minvalue, maxvalue and cycle keyword.

Selecting the sequnce. Every time the next value for CyclingSequence is called the sequence is incremented by 25. When it reaches the maxvalue it starts again from the minvalue.

Result of the selection.


If you have a note or a question please write a comment.

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s