Solved

put 0 in front of integer in sql table field

Posted on 2014-03-16
2
774 Views
Last Modified: 2014-03-16
trying to display 01134214124124 in sql server table field,

it displays 1134214124124

is there ways to configure in table designer to achieve it?
0
Comment
Question by:doramail05
2 Comments
 
LVL 21

Accepted Solution

by:
Dale Burrell earned 500 total points
Comment Utility
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
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Dale's right, numbers do not have leading zeros.  Only text displays do that.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now