Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 text before @ symbol of email address column

Author  Topic 

kieran5405
Yak Posting Veteran

96 Posts

Posted - 2011-07-08 : 10:13:14
hi,

i am selecting a column with email addresses in it. i now need to also select just the text before the '@' symbol of the email addresses.

how can i do this?

thanks for any help...

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-07-08 : 10:15:42
case when charindex('@',yourField,0) > 0 then Substring(yourField,1,charindex('@',yourField)) else null end

Corey

I Has Returned!!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-07-08 : 10:57:20
quote:
Originally posted by Seventhnight

case when charindex('@',yourField,0) > 0 then Substring(yourField,1,charindex('@',yourField)-1) else null end

Corey

I Has Returned!!



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kieran5405
Yak Posting Veteran

96 Posts

Posted - 2011-07-08 : 12:41:56

thanks i got that working great. i just want to highlight for others looking for this solution...that at first glance i didnt see the '-1' in red in the 3rd post and copied the 2nd. without the -1 the @ symbol still remains...but thanks to both contributors for their help.
Go to Top of Page
   

- Advertisement -