Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to generate auto genarete id number in sql server,

I need a adding my From Auto increment ID number.My id number Format is
INV001.How to genarete a this kind of id Number.


I use this one .It only Numbers.i Need a ID number with character.
SQL
CREATE TABLE Persons
(
  ID int IDENTITY(1,1) PRIMARY KEY,
  PRIMARY KEY (ID)
)


Anyone can help me.Thank You
Posted
Updated 3-Oct-13 18:48pm
v3

CREATE TABLE Persons
(
ID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (ID)
)
 
Share this answer
 
Try This

Right Click on table you want to add increment and goto design mode.
Select the primary key and see below
You can see + in Identity Specification make that yes and click on that +
and select the increment ie. 1,2,3 and select the identity seed 1,2,3 or whatever u like

identity seed means the point you want to start from and identity increment is the value that you like to increment by

for eg. if you select 2 as identity increment and 5 as identity seed then the output will be
5
7
9

for eg. if you select 1 as identity increment and 1 as identity seed then the output will be
1
2
3
 
Share this answer
 
Using Sequence in SQL Server. I think that will definitely serve your purpose. Check this link for more information -

http://technet.microsoft.com/en-us/library/ff878091.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900