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

Recommended Answers

All 3 Replies

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.

*Not to mention I used Pubs database and worked on Authors table (address column)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.