Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have a table xyz and have two columns one store date as varchar and other store sequence of six digit 000000 to 999999 having datatype varchar.

i want to update my sequence +1 and the new generated sequence as 000001
000002
000003

how wil i do this ?

please help
Posted
Comments
Pikoh 4-Sep-14 3:40am    
Not enough info. That table,how many rows contains? One or several? And the increment depends on the previous row value or the same row value?
_Asif_ 4-Sep-14 4:13am    
Why can't you add a new column with IDENTITY on and drop the existing sequence column?

1 solution

CREATE TABLE xyz (
_ID int IDENTITY(1,1) not null,

id as RIGHT('0000' + CONVERT(varchar(6),_ID),6),

)
 
Share this answer
 
v2

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