aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

SQL Server Add Auto Increment Column or Set Auto Increment Column SQL Server Management Studio

Nov 25, 2013

Here I will explain how to set or add auto increment column in SQL server or create auto increment column in SQL server 2008 using management studio.

In many situations we will insert records in table during that time we need to set unique value for that record if we use auto increment column then automatically generate unique number for newly insert record in table (Like generate EmployeeID of each employee whenever employee record inserted).
To set auto increment column in table we have different methods

First Method

After completion of table creation open table in design mode and select column for which we need to set identity column. Now go to column properties in that select Identity Specification >> Is Identity

Now change the property of Is Identity from “NO” to “YES

After change Is Identity property to “YES” Give Identity Increment value (This is the value which will add for every row inserted) generally this value will be 1 whenever new record inserted column value increases 1 if you want to more value change that value.

If you observe we have another property called Identity Seed this property is used to set starting value of column. Suppose if you want to start column value from 1000 change Identity Seed value from 1 to 1000.

Now our column is ready here we need to remember one point that is to insert new record in table we don’t want to specify value for the column which contains Identity property automatically unique value will added for that column.

Ex:  Insert into UserDetails (UserName, FirstName, LastName, Email) VALUES (sureshdasari, Suresh, Dasari,

After insertion our table will be like this


Second Method

We can set auto increment column through query like this

UserName varchar(200),
FirstName varchar(255),
LastName varchar(255),
Email varchar(255)

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Avil Anil said...

sir,I Have two tables and i am displaying the datas using a gridview by using view in sql server i need to implement drop down search thats all are working fine but i need to Change in this by using login form when a user logins his username gets saved automatically by using session but while i am displaying in grid i am getting this username its the id we have given for the corresponding user but related to that id i need to match the correct username thats given in another colomn in login table and needs to display in gridview can u please give me a idea how to implement this. Iam trying from last 2 days not getting please help me....

Anonymous said...


Anonymous said...

Hi could you please tell me that how to create identity column in stored procedure...

Give your Valuable Comments

Other Related Posts

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.