Terri (6/10/2009)
Good explanation Jeff. A small point, your solution fails if there is more than 1 space between the 2 words. e.g 'Lincoln Lincoln' has length 16. So the left half is 'Lincoln ' and the right half is ' Lincoln'.This is fixed by adding RTRIM and LTRIM to left and right half respectively:
WHEN RTRIM(LEFT(Address,LEN(Address)/2)) = LTRIM(RIGHT(RTRIM(Address),LEN(Address)/2))
Of course, there are probably other scenarios that don't work, but the OP needs to test with his data. 🙂
Yep... good enhancement. The best thing, of course, would be to pork chop the silly person who made the mistake of combining the data to begin with. 😉 Solutions for to correct these types of mistakes are bound to have a flaw here and there.
--Jeff Moden
Change is inevitable... Change for the better is not.