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 |
|
mdelgado
Posting Yak Master
141 Posts |
Posted - 2002-07-23 : 15:22:18
|
| For some reason, I'm having trouble figuring this out although I'm sure the answer is simple.I have a varchar column with the following values:8237241224How can I display them like this in a query?082307241224In other words; make the column 4 wided padded left with zeroes.thanks. |
|
|
joshb
Yak Posting Veteran
52 Posts |
Posted - 2002-07-23 : 15:41:35
|
| Here's one way:SELECT REPLICATE('0', 4-LEN(Val)) + ValJosh |
 |
|
|
mdelgado
Posting Yak Master
141 Posts |
Posted - 2002-07-23 : 15:50:58
|
| EXCELLENT!!thank you. |
 |
|
|
drymchaser
Aged Yak Warrior
552 Posts |
Posted - 2002-07-23 : 16:25:47
|
| Another:select right(('0000'+<fieldname>), 4) |
 |
|
|
mdelgado
Posting Yak Master
141 Posts |
Posted - 2002-07-23 : 16:31:56
|
| Even Better Thanks. |
 |
|
|
|
|
|