Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Right Justify data in a column

Status
Not open for further replies.

Idokyoku2

Technical User
May 16, 2004
57
US
Hello,
I need help flushing data to the right of a column Char(100). I've tried something like this:

update tbl02
set BusAddr = ' '+RTRIM(BusAddr);

Data does move to the right some, but I receive a termination error, since some data would be truncated.
This is problematic since length of data varies.

Anyone have a better statement/idea?
David

 
1. Don't use char(100), prefer varchar(100)

2. Try not to format data in DB table. Store strings naturally left-aligned, format results either at runtime or outside database.

3. To right-align data at runtime, try RIGHT(REPLICATE(' ', 100)+RTRIM(BusAddr), 100)
 
Right on! That worked perfert!

You're my new best friend!

Thanks a ton.
David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top