Don't see the Zero(0) when do select | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Don’t see the Zero(0) when do select

Hi, i’ve create a table that have cell phone column(int) and social_security (int) for my testing environment. the problem is when i add a record that start with the Zero number when i do that SELECT statement i can’t see the first Zero number in the results even if i add the number that start with Zero in (‘0212545’).Why is that?
The int datatype wont store leading zeroes. 1 If Zip codes have fixed lenght use CHAR(7) and insert values with leading zeroes
2 If you use front end application, then use INT datatype and when displaying format it there using Format function Madhivanan Failing to plan is Planning to fail
quote:Originally posted by Madhivanan The int datatype wont store leading zeroes. 1 If Zip codes have fixed lenght use CHAR(7) and insert values with leading zeroes
2 If you use front end application, then use INT datatype and when displaying format it there using Format function Madhivanan Failing to plan is Planning to fail
ok i did change the value from int to char(9) but only if i insert the numbers with ‘0454654’ it show the Zero number but if i insert numbers like that 0454654 it dosen’t show the Zero
To add data to CHAR datatype you need to pass value within sigle quote like ‘0454654’ Madhivanan Failing to plan is Planning to fail
To understand why it is as it is, read up in BOL for data type precedences. —
Frank Kalis
Microsoft SQL Server MVP
Contributing Editor, Writer & Forum Moderatorhttp://www.sql-server-performance.com
Webmaster:http://www.insidesql.de
]]>