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 |
iloveorangesoda
Starting Member
30 Posts |
Posted - 2008-04-16 : 06:08:16
|
I am doing a select statement from a table and want to pad a field with a zero if the value is between 1 and 9. The field is a char(2)Anyone give me example of how to do this.cheers |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-04-16 : 06:16:24
|
[code]select right('00' + rtrim(col),2) as col from table[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
iloveorangesoda
Starting Member
30 Posts |
Posted - 2008-04-16 : 07:46:28
|
great thanks |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-16 : 08:34:04
|
quote: Originally posted by harsh_athalye
select right('00' + rtrim(col),2) as col from table Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
Orselect right('0' + rtrim(col),2) as col from tableProvided the column is not emptyMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|