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 |
|
mdhingra01
Posting Yak Master
179 Posts |
Posted - 2004-08-05 : 09:30:40
|
| Is there a way to pad a cell with '0'. For instance a field in the Table A should be 16 characters in length. I am feeding into this table, so if the data being fed is less than 16, then I want to pad to the left of the data with '0'.Thanks |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-08-05 : 09:39:32
|
| SELECT RIGHT(REPLICATE('0', 16) + LTRIM(RTRIM(FileldA)),16)FROM TableADuane. |
 |
|
|
mdhingra01
Posting Yak Master
179 Posts |
Posted - 2004-08-05 : 10:39:11
|
| Thanks Duane! |
 |
|
|
Pat Phelan
Posting Yak Master
187 Posts |
Posted - 2004-08-05 : 13:38:53
|
As long as you don't need to cope with negative numbers, I've always liked:SELECT Replace(Str(FieldA, 16), ' ', '0') -PatP |
 |
|
|
|
|
|