December 17, 2003 at 3:56 pm
Hi,
I have a text column in my SQL database table which stores comments from users (including email addresses). Is there a way I can extract only EMAIL address out of this column and store it into another column (in the same table or another table)?
If this question is already asked, I apologize for re-posting. Please redirect me to the old one, I couldnt locate it.
thank you all in advance,
v
December 17, 2003 at 10:01 pm
Hi,
Can U provide some sampe data...so that I can build a query.
Madhu
Madhu
December 18, 2003 at 1:01 am
Yes, without sample data it's difficult.
I have done something similar in a small app outside SQL Server
Basically you need to search for the @ sign, then take all characters to the left of it till it is a blank and again all characters to the right of @ till it is a blank.
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 18, 2003 at 6:38 am
If your data conforms to Franks post.
SELECT
STUFF(SUBSTRING(textcol,1,CHARINDEX(' ',textcol,CHARINDEX('@', textcol))-1),1,
CHARINDEX('@', textcol) - CHARINDEX(' ',
REVERSE(SUBSTRING(textcol,1,CHARINDEX('@', textcol)-1))),'')
FROM
Edited by - davidburrows on 12/18/2003 06:43:00 AM
Far away is close at hand in the images of elsewhere.
Anon.
December 18, 2003 at 6:42 am
or
SELECT
SUBSTRING(SUBSTRING(textcol,1,CHARINDEX(' ',textcol,CHARINDEX('@', textcol))-1),
CHARINDEX('@', textcol) - CHARINDEX(' ',
REVERSE(SUBSTRING(textcol,1,CHARINDEX('@', textcol)-1))) + 1,255)
FROM
Far away is close at hand in the images of elsewhere.
Anon.
December 18, 2003 at 7:59 am
Thank you guys for responding to my query, the sample data in this column looks like:
comments;l;comments, more comments
NULL
NULL
email::test@microsoft.com;comments
email: test@microsoft.com;;;comments
NULL
the data is basically a mix of everything.
thank you,
v
David: I am working with your suggestion, but am getting an error saying "Invalid length parameter passed to substring function". I am assuming it has something to do with null data. But I dont know.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy