Click here to Skip to main content
15,748,748 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
Dear i want to generate user specific auto increment code . like

i m creating a lead sheet . than when we submit and save it in database its id should be create like this : LS_001 for next entry . it should be , LS_002

Try like this

CREATE      TABLE dbo.TestTable
name int ,
  FormatColumn AS RIGHT('LS_00' + CAST(ID AS VARCHAR(8)), 6) PERSISTED

insert into TestTable ( name) values (1)
insert into TestTable ( name) values (2)
insert into TestTable ( name) values (3)

select * from TestTable
Share this answer
Rohit85 28-Jan-14 2:23am    
This Is Successfully Run .
Rohit85 28-Jan-14 5:02am    
Karthik tell me one thing if i run this code to Ms Access Data base it will run with same code or i have to change some where
can you please check it out this...

Auto-incremented ID with NVARCHAR/VARCHAR datatype[^]

you need to work around and need to change accordingly to your requirement.
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