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 - 2012-05-21 : 14:24:58
|
| How do I add leading spaces to a field?Need to make sure the value is 20 characters long with leading spaces. '632' needs to become ' 632' |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2012-05-21 : 14:40:14
|
Usually it's Trailing spacesIst it coming from a column or a local variable?DECLARE @x varchar(255)SET @x = '632'SELECT '"'+@x+'"'SELECT '"'+RIGHT(space(20)+@x,20)+'"' AS [@x+20] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-21 : 16:06:55
|
quote: Originally posted by Vack How do I add leading spaces to a field?Need to make sure the value is 20 characters long with leading spaces. '632' needs to become ' 632'
STR(field,20)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-05-22 : 06:31:45
|
| This is related to formatting. If you use front end application do the formation thereMadhivanan Failing to plan is Planning to fail |
 |
|
|
|
|
|