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

SQL 2012 RTRIM with Right string help 1

Status
Not open for further replies.

ITALIAORIANA

Technical User
Apr 22, 2005
103
US
Hi, I am trying to pull a query to get the right 3 characters in a field. I need to right trim the field first. What I wrote is not working. It returns blanks. I would appreciate any help with this. I've tried several variations of rtrim and right string to no avail. I eventually want to update another table field with these results.

SELECT RTRIM(RIGHT(CSCS_DESC,3) FROM CSCS_TABLE


Thanks,
Deana
 
It would help if you provided some sample data. Also, your expression is missing a ")". Can we assume this is a typo?

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Whoops yep that was a typo (fixed below). In the description field I have a description and a 3 digit code at the end. The characters in that field are variable and I only need the 3 digit code.

SELECT RTRIM(RIGHT(CSCS_DESC,3)) FROM CSCS_TABLE


Example of data in field.
Utah - 216
Alaska - 034
California - 032

Results I need
216
034
032

Thanks
Deana
 
Change the order of the RTrim and the Right, SELECT RIGHT(TRIM(CSCS_DESC),3) FROM CSCS_TABLE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top