[Company Logo Image] 

Home Up Contents Coffee Break Credits Glossary Links Search

 
Sequence Objects

 

 

Home
Analysis Services
Azure
CLR Integration
High Availability
Open Source
Security
SQL Server 2008
SQL Server 2012
SQL Server 2014
SQL Server 2016
SQL Server 2017
SQL Server 2019
Tips
Troubleshooting
Tuning

Sequence Objects.


Applies to: SQL Server 2012, SQL Server 2014.


SQL Server 2012 introduced sequences as a new way to generate incremental sequential values that can be used for table primary keys. Sequences can be used instead of identity columns.

Benefits.

1. Sequences can improve insert performance. Sequences offer better performance on tables receiving huge amount of inserts.

2. Sequences allow to know the last primary key value used without having to read the last record inserted or without using SCOPE_IDENTITY.

3. Sequences offer a way to generate a unique key value that can be used for many tables on a relational database.

 

Example.

The following T-SQL script creates a sequence that starts at 100 and increments by 1, and uses
the next available value in the sequence as the default value for service desk ticket numbers.
 

 

 

 

.Send mail to webmaster@sqlcoffee.com with questions or comments about this web site.