You are here: Re: Find website from email address « MsSQL Server « IT news, forums, messages
Re: Find website from email address

Posted by Dan Guzman on 07/04/07 15:47

> Would anyone be able to help me with the SQL that would take whatever is
> after the '@' sign in the email address, add it to 'www.' and populate the
> 'website' field?

Here's one method:

UPDATE dbo.MyTable
SET website =
CASE WHEN CHARINDEX('@', email) > 0 AND CHARINDEX('@', email) + 1 <
LEN(email) THEN
'www.' + SUBSTRING(email, CHARINDEX('@', email) + 1, 255)
ELSE
website
END
WHERE
website IS NULL OR
website = ''

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Mintyman" <mintyman@ntlworld.com> wrote in message
news:f6gap5$qgb$1$8300dec7@news.demon.co.uk...
> Hi,
>
> I have 2 fields in a database: 'email' and 'website'.
>
> In the majority of cases, the website field is not populated even though
> the email address is. In 90% of cases, the website will be 'www.' followed
> by whatever is after the '@' symbol in the email address.
>
> Would anyone be able to help me with the SQL that would take whatever is
> after the '@' sign in the email address, add it to 'www.' and populate the
> 'website' field?
>
> Thanks!
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация