Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Apples
Posting Yak Master
146 Posts |
Posted - 2009-01-14 : 14:50:00
|
| I'm trying to store an integer in a table as "07" but it gets put in there as "7".I want all the integers to have 2 digits; if they are a single digit number, they should have a zero in front of it.How can I do this? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2009-01-14 : 14:56:00
|
| Integer columns do not have a defined display format, except in the context of an application.If you want a leading zero on value stored as integer datatype, you can add that when you retrieve it from the database, or let your front-end application handle the formatting.CODO ERGO SUM |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-01-14 : 15:03:12
|
quote: Originally posted by tkizer You must use a character data type, such as char or varchar.Tara Kizer
and if you're doing that remember 07 is now not same as 7 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-14 : 23:59:41
|
quote: Originally posted by Apples I'm trying to store an integer in a table as "07" but it gets put in there as "7".I want all the integers to have 2 digits; if they are a single digit number, they should have a zero in front of it.How can I do this?
mke field as varchar and useRIGHT('0' + integervalue,2) for value |
 |
|
|
|
|
|