Question : SQL 2005 Select query


I have a Column Email.. I need to select 2 things

I need 1 column to select the name of domain

The second column the entire Sympatico address

for example an address [email protected]

column 1 should return ---> aol
Column 2 should return --->aol.com

another example
address [email protected]

column 1 should return ---> yahoo
Column 2 should return --->yahoo.net


 

Answer : SQL 2005 Select query

try the below:

1:
2:
3:
4:
select 
	substring(email, charindex('@', '@'+email)+1, charindex('.', email+'.', len(email)-charindex('@', '@'+email))-1) as col1,
	right(email, isnull(nullif(charindex('@', reverse(email)), 0), len(email)+1)-1) as col2
from yourtable
Random Solutions  
 
programming4us programming4us