Click here to Skip to main content
15,888,031 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I m inserting value of Id as 0001 but it is showing 1 in database

I have 7 fields in my datafield

ID is set as Identity it is possible to show ID like this 0001 instead of 1

or I have to take another ID of different name with datatype int
Posted

1 solution

Datatype int will display it as a number only. There is no way you can change it. You can create a select query to show it as 0001, but it will be stored as 1 only.
SQL
select right('0000' + convert(varchar(4),yourField), 4) from yourTable
 
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