I have Employee table with Empolyee ID column
EmpID (nvarchar(5)) ,
and I want to make
EmpID's value to
00001 00002 00003 00004 .... ....
How can I make Custom Auto-Generated Sequences likes this ?
closed as off-topic by Jon Seigel, StanleyJohns, Nick Chammas, Mat, dezso Sep 22 '13 at 8:52
I would recommend to let SQL Server handle the auto-incrementing part by using an
For your second column that you want to have in a specific, formatted fashion, use a computed column based on that identity column.
Try something like this:
That way, when you insert rows into the table, you'll get:
Sequences like this are easy with SQL Server 2012; unfortunately they are not supported in SQL Server 2008 R2. However, you can create your own method of generating sequences like:
Look at this site for further details (which is where I obtained the above code!)