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

Getting the String (from the end)

Status
Not open for further replies.

RemingtonSteel

Programmer
Jul 14, 2006
65
GB
What is the string function in SQL if I want to start getting the string from the end.

For example:

Intended Result

Hamilton, ON, CAN -> CAN
Regina, SK, CAN -> CAN

Thanks!
Gene
 
[ ]

Maybe something like:

[tt]
originalstring = "Hamilton, ON, CAN"
resultingstring = ATXRIGHT(originalstring, ', ')
[/tt]


See faq184-5975 for the code for the ATXRIGHT UDF.

mmerlinn


"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond
 

I would suggest something as simple as
Code:
string1="Hamilton, ON, CAN"
string2=ALLTRIM(RIGHT(st1,LEN(st1)-RAT(",",st1)))
?st2
but you said, "in SQL"? Do you mean SQL Server or you just meant VFP's own SELECT-SQL?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top