Reputation: 2381
I have the following working query :
SELECT
REPLACE(
AddressLine1, RIGHT( AddressLine1, 5 ),
UPPER( RIGHT( AddressLine1, 5 ) )
)
FROM Person.Address
There is other way to do that ?
Upvotes: 2
Views: 63
Reputation: 1269693
Use concatenation:
select left(addressline1, len(addressline1) - 5) + upper(right(addressline1, 5))
from person.address;
Your method is dangerous, because there is no guarantee that the last five characters only appear once in the address.
Hmmm, you can also do:
select stuff(addressline1, len(addressline1) - 4, 5, upper(right(addressline1, 5)))
from person.address;
Both these formulations assume that addressline1
has at least 5 characters. If shorter addresses are possible, then a case
is probably the easiest solution.
Upvotes: 1