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 |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-07-02 : 07:19:05
|
Will writes "How would you right justify a character field in query?" |
|
setbasedisthetruepath
Used SQL Salesman
992 Posts |
Posted - 2003-07-02 : 09:33:05
|
Why would you want to? Formatting is a presentation layer issue.If you really really want to, however, read up on REPLICATE() in BOL.Jonathan{0} |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2003-07-02 : 09:34:13
|
You should really be doing this at the presentation layer. But anyway something like this will do it:USE NorthwindSELECT space(50 - len(companyname)) + companyname FROM customersOwais |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-07-02 : 12:35:07
|
orright justificationselect right(replicate(' ',50) + companyname,50) from customersleft justificationselect left(companyname + replicate(' ',50),50) from customersreplace the char in the replicate statement with your padding character.This sort of thing will work in most languages.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
|
|
|