0

Hi all,

In a table column, I have this address value:

"Muehlgasse 1 86637 Wertingen GERMANY"

I want to get only the GERMANY part on my SELECT code. I've tested this code:

SELECT right('Muehlgasse 1 86637 Wertingen GERMANY',7)

It works, but the '7' has to be calculated, because we have other countries, too.

Any idea?? Thanks

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by andresasongko
0

Dear Andresasongko,

select 
REVERSE
(
substring(
	REVERSE(address)
	, 0
	, CHARINDEX(' '
				, REVERSE(address)
				,0
				)
)
)
,address from authors

That's what I tried right now, you can work to perform it better.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.