I wanted to get the domain name from the email in a query..
So if the email is aj70000@.hotmail.com, I just to display hotmail.com
Thanks in advance for the help.
AJ"AJ" <aj70000@.hotmail.com> wrote in message news:6097f505.0405241104.ce751b1@.posting.google.co m...
> Hi,
> I wanted to get the domain name from the email in a query..
> So if the email is aj70000@.hotmail.com, I just to display hotmail.com
> Thanks in advance for the help.
> AJ
Assume table T with relevant column email_address.
SELECT SUBSTRING(email_address,
NULLIF(CHARINDEX('@.', email_address), 0) + 1,
LEN(email_address) - CHARINDEX('@.', email_address) + 1)
AS domain_name
FROM T
--
JAG|||AJ (aj70000@.hotmail.com) writes:
> I wanted to get the domain name from the email in a query..
> So if the email is aj70000@.hotmail.com, I just to display hotmail.com
declare @.str varchar(30)
select @.str = 'aj70000@.hotmail.com'
select substring(@.str, charindex('@.', @.str) + 1, len(@.str))
I encourage you to look up the functions I used in Books Online.
--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
No comments:
Post a Comment