Refer -
SQL Identity with leading padded zeros[
^].
Quote:
create table Identitytest(
number int identity(1,001) not null,
value varchar(500)
)
But it will store them as 1, 2, 3 ...
If you want to show them by leading zeros, then follow the answer...
Quote:
If you want to display your number
column with leading zeros, just pad it in your SELECT
statement. It's a number, it will NOT store with leading zeros as an integer.
SELECT RIGHT('00000' + CAST([number] AS varchar(5)) , 3)
FROM IdentityTest
The 3
is the number of characters you want total in the output display.