Hi,
How to make (int) Identity auto increment field showed like
0001
0002
0003
0004
...
Lew:
To perform the formatting you ask about will require a little code and will require converting your IDENTITY column to VARCHAR or NVARCHAR -- something like:
right('000'+convert(varchar(4),anIdentity),4)
For example:
declare @.anIdentityTable table (anIdentity integer identity)
insert into @.anIdentityTable default valuesselect anIdentity,
right('000'+convert(varchar(4),anIdentity),4) formattedIdentity
from @.anIdentityTable-- anIdentity formattedIdentity
-- -- --
-- 1 0001
No comments:
Post a Comment