Link to home
Start Free TrialLog in
Avatar of singhrkp
singhrkp

asked on

Right/ Left Justify

I want to know that how can we right / left justify a text field for example if we have char/varchar field of width 15 and only 4 chars exists in table so when we use select fielname from tablename then fieldname must be right justifies with blank padded at its left side.

It should look like following
fieldname
           xxxx
Avatar of gletiecq
gletiecq

Do you want the database to prepend blanks in order to right-justify?  Or is this a question about how to make the application display data differently?

Greg
ASKER CERTIFIED SOLUTION
Avatar of DaniPro
DaniPro
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I guess you need a + operator ..

select left((space(15) + convert(varchar, myField)),15) from tablename