Reputation: 5069
I have string something like this
'myname' <[email protected]>
or like this
I want to extract domain from both kind of strings
For 2nd I can do somthing like this
select RIGHT(email, LEN(email) - CHARINDEX('@', email))
but same is not working for 1st string.
Also I do not know in which format email address will come
I am using Sql Server 2014.
Upvotes: 0
Views: 89
Reputation: 1271211
You can use stuff()
and replace()
:
select replace(stuff(email, 1, charindex('@', email), ''), '>', '')
Here is a db<>fiddle.
Upvotes: 3