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 |
Vack
Aged Yak Warrior
530 Posts |
Posted - 2014-07-08 : 13:16:21
|
I have a char(8) ord_no field which has leading zeros. I want to replace them with leading spaces. I've tried:select right(' '+cast(convert(int,ord_no)as CHAR(8)),8)This does not work. |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2014-07-08 : 13:24:00
|
quote: Originally posted by Vack I have a char(8) ord_no field which has leading zeros. I want to replace them with leading spaces. I've tried:select right(' '+cast(convert(int,ord_no)as CHAR(8)),8)This does not work.
try:select right(' '+cast(convert(int,ord_no)as VARCHAR(8)),8) I believe (not sure) the cast of an int to char(8) will add trailing spaces...but you have not posted what you mean/what is the result when you say "does not work". Too old to Rock'n'Roll too young to die. |
|
|
|
|
|