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 |
|
Knarf180
Starting Member
42 Posts |
Posted - 2004-10-01 : 11:07:33
|
| I'm building a report off my database and I need to convert an INT into a varchar. The problem is that I need to make sure the INT is always 3 characters long, if 1 or 2 then it must have leading 0s. Ex. 1 = 001 23 = 023I think the format() command should be able to do this but I cant seem to find any information on how to use it.Thanks. - Frank |
|
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2004-10-01 : 11:47:41
|
| Somthing like this. Select right('00' + convert(varchar, a.col),3) from (Select 1 as 'col' union select 23 union select 235) as a- Sekar |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-10-01 : 13:31:36
|
| make your life easer and format on the report itself, not by using T-SQL.- Jeff |
 |
|
|
tuenty
Constraint Violating Yak Guru
278 Posts |
Posted - 2004-10-01 : 17:59:07
|
quote: Originally posted by jsmith8858 make your life easer and format on the report itself, not by using T-SQL.
good pointBut if you (Frank) don't agree then go to http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=40710*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*A candle loses nothing by lighting another candle |
 |
|
|
|
|
|