Skip to Content
What's New in SQL Server 2012
book

What's New in SQL Server 2012

by Rachel Horder
October 2012
Intermediate to advanced
238 pages
5h 17m
English
Packt Publishing
Content preview from What's New in SQL Server 2012

SEQUENCE

You are no doubt used to IDENTITY and how this works with a seed and increment value. SEQUENCE is structured in a very similar way, but with fewr limitations, giving it a welcome flexibility.

A SEQUENCE object is created at the database level but, unlike an IDENTITY property, it can be used across multiple tables. An IDENTITY value is generated when you insert a row into a table and it cannot be updated. You can retrieve the SEQUENCE value at any time and reset it without altering its previous value, and even set a minimum and maximum value. Let us look at a simple example:

CREATE SEQUENCE mySequence AS int
START WITH 1
INCREMENT BY 1

As you can see, mySequence is now available for use by all tables in the database:

We have not used the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft® SQL Server 2012 Unleashed

Microsoft® SQL Server 2012 Unleashed

Ray Rankins, Paul T. Bertucci, Chris Gallelli, Alex T. Silverstein
Pro SQL Server 2012 Practices

Pro SQL Server 2012 Practices

Bradley Ball, TJay Belt, Glenn Berry, Jes Borland, Carlos Bossy, Louis Davidson, Ben DeBow, Grant Fritchey, Jonathan Gardner, Jesper Johansen, Jeremy Lowell, Wendy Pastrick, Kellyn Pot'vin, Mladen Prajdić, Herve Roggero, Chris Shaw, Gail Shaw, Jason Strate
Microsoft® SQL Server 2005 Unleashed

Microsoft® SQL Server 2005 Unleashed

Ray Rankins, Paul Bertucci, Chris Gallelli, Alex T. Silverstein, Tudor Trufinescu, John Kane

Publisher Resources

ISBN: 9781849687348Other