Link to home
Start Free TrialLog in
Avatar of delic8te
delic8te

asked on

Email Domain Extraction

Hello peeps!
Am in desperate need to extract all domain names from an email field - so mel@mel.com will return @mel.com - any ideas on what the sql code will be to do this?
Thanks

ASKER CERTIFIED SOLUTION
Avatar of HuyBD
HuyBD
Flag of Viet Nam image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aneesh
DECLARE @email varchar(400)
SET @Email = 'aneeshattingal@hotmail.com'
SELECT SUBSTRING(@Email, Charindex('@',@Email)+1,Len(@Email)-Charindex('@',@Email)+1)
if you need '@' then


DECLARE @email varchar(400)
SET @Email = 'aneeshattingal@hotmail.com'
SELECT SUBSTRING(@Email, Charindex('@',@Email),Len(@Email)-Charindex('@',@Email)+1)
Avatar of delic8te
delic8te

ASKER

thanks - however, I need this to be an update query......???

update yourtable set domain=right(email,len(email)-charindex('@',email))
yep - of course - have a silly moment - just figured it out myself - thanks again :)
how about address lines?? extracting a postcode from a address?