put 0 in front of integer in sql table field

trying to display 01134214124124 in sql server table field,

it displays 1134214124124

is there ways to configure in table designer to achieve it?
LVL 1
doramail05Asked:
Who is Participating?
 
Dale BurrellConnect With a Mentor DirectorCommented:
You might be getting confused between data storage and data display - they are quite different.

If you store a number in SQL Server then you are storing that number - there is no such thing as a leading zero for a number.

When you come to display it you can of course add a leading zero, but you would normally do that in your application code?

If you do need the SQL itself to add a leading zero you need to convert it to a string e.g.

select '0' + convert(varchar(13),MyNum) from (select 1134214124124 MyNum) x

Open in new window


And if you do that you can easily count the number of digits in the number and add a variable number of zeros to the front if that is what you need.
0
 
Dave BaldwinFixer of ProblemsCommented:
Dale's right, numbers do not have leading zeros.  Only text displays do that.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.