March 26, 2008 at 8:20 am
This seems to me to be a really simple thing but I am stumped.
I am going to create login names by removing the @companyname.com from people's e-mail addresses. The company names are all different so it isn't as easy as just removing a known set of characters. Any ideas? Thanks!
March 26, 2008 at 8:26 am
Pam Pinnacle (3/26/2008)
This seems to me to be a really simple thing but I am stumped.I am going to create login names by removing the @companyname.com from people's e-mail addresses. The company names are all different so it isn't as easy as just removing a known set of characters. Any ideas? Thanks!
Assuming that the @ character doesn't appear anywhere else in the email address and assuming it appears once you could do something like this:
select substring(EmailAddress,1,charindex('@',EmailAddress)-1)
--or if you want to update an existing table
update my_table
set login = substring(EmailAddress,1,charindex('@',EmailAddress)-1)
Hope that helps.
March 26, 2008 at 8:27 am
try
select substring(@email, 1, charindex('@', @email)-1)
Dragos
April 3, 2008 at 8:40 am
Thanks so much! Those did the trick
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply