Powered by Blogger.

Saturday, February 15, 2014

Difference between Sequence and Identity in Sql Server

In this post we will discuss some of the difference between Sequence and Identity in Sql Server. Also you can check out my previous posts on:

- How to open hyperlink in new tab using jQuery or JavaScript?

- Array and ArrayList in C#.Net

- Difference between primary key and foreign key in SQL server

Sequence is a new concept comes with SQL Server 2012, You can check out more here.

Below are some of the differences between Sequence and Identity Column in SQL Server:

- Identity columns are specific to tables inside a database, where as Sequence is not for any table specific, it can be used in whole database.

- Identity columns values generated when a row inserted to a table, but you can get the sequence number before inserting a row.

- You can not change the value of the Identity column once inserted, but the sequence number can be changed after insertion into the table.

- Identity column guarantees uniqueness inside the table, but in case of Sequence you need to create unique index on the column.

- In case of Identity column, you cannot define minimum and maximum values, whether to allow cycling, and caching options or not. But these things can be archived through Sequence in Sql Server 2008.