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.
Author |
Topic |
Najju565
Starting Member
6 Posts |
Posted - 2014-01-28 : 05:41:05
|
Display Name Column in DISPLAY_DETAILS Table contains data as: Joe Barnard(123456)<Joe.Barnard@SQLTeam.com>;Paul Johnson(114454)<Paul.Johnson@SQlTeam.com>; Need to pull Email Address of Individual Employees.need result like this:Joe.Barnard@SQLTeam.com;Paul.Johnson@SQlTeam.comPlease help on the same. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-01-28 : 06:00:55
|
[code];WIth CTEAS(SELECT t.PK,REPLACE(STUFF(f.Val,1,CHARINDEX('<',f.Val),''),'>','') AS EmailAddrFROM DISPLAY_DETAILS tCROSS APPLY dbo.ParseValues(t.DisplayName,';')f)SELECT PK,STUFF((SELECT ';' + EmailAddr FROM CTE WHERE PK = t.PK FOR XML PATH('')),1,1,'')FROM (SELECT DISTINCT PK FROM CTE)t[/code]PK is primary key of your tableParseValues can be found herehttp://visakhm.blogspot.com/2010/02/parsing-delimited-string.html------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
|
|
|