Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Dear All,I need to extract all the emailaddress from 'comment' field in customer tablefor ex:Commentsampltextsam[mailto:myname@aol.com]pltextsampltextsampltextsaampltextssampltextsampltextsampltextsampltextsaamplt[mailto:testname@gmail.com]outputmyname@aol.comtestname@gmail.comEmail address is hidden in this string field.I Need to find and extract.Any help regarding this will be highly appreciated!ThanksRegards,SG
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2012-06-18 : 11:57:55
if the format is consistent as shown above you can use logic like'
SELECT STUFF(STUFF(Comment,1,PATINDEX('%[mailto:',Comment)+8,''),CHARINDEX(']',Comment),LEN(Comment),'') AS emailaddress FROM Table
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2012-06-20 : 07:29:11
orselect substring(comment,1,charindex('.com',comment)+3) from(select substring(comment,charindex('mailto:',comment)+8,len(comment)) as comment from table ) as tMadhivananFailing to plan is Planning to fail