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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I RIght Justifiy a field

Status
Not open for further replies.

isonlyme

Programmer
Apr 20, 2002
171
PR
Hi

I have a table with a field char (10)

the records on that field some have 3 spaces on the left and the rest doesnt have spaces on the left example:

the line underscore (___) means space in the left for demostration purpose

"__MYDATA"
"MYDTA__"

I want all the data to be like this "__MYDATA"

Im doing this: upadte tablebame set myfield = rtrim(myfield)

but it doesnt change anything

Any suggestions please this is rush

THANKS!!
 
Code:
UPDATE MyTable SET MyField = RIGHT(SPACE(10)+LTRIM(RTRIM(MyField)),10)

Borislav Borissov
 
Be sure to note somewhere that you did this and why. THis type of stuff has a way of causing developers grief down the road when they are querying for something and 'MYDATA' returns 0 rows because of padding.

Shoot Me! Shoot Me NOW!!!
- Daffy Duck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top