question

klemmyjb avatar image
klemmyjb asked

concatinate

I need help with this query please Demand contains name in mulpile (example jame dave, Daniel toy) which reference email addrees from email table Problem : result was blank because of the double names in Demand table I am trying to write a query maybe (concatenate) which will pull the 2 email address from email table SELECT [Name] = a.[name], [Demand] = a.[Demand], [Email] = u.[email] FROM [appl] a LEFT JOIN [sys] u ON u.[name] = [a].[demand];
sql-server-2012
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

anthony.green avatar image
anthony.green answered
So your going to have to split the input string "jame dave, Daniel toy" into two parts, I recommend Jeff's delimited split function http://www.sqlservercentral.com/articles/Tally+Table/72993/ to do that to get the individual persons email address, then code around it to join the result set into a large string to pass into the mail, or as much as it pains me to say it a loop to loop through the result set to send individual mails
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sajikumar.vk avatar image
sajikumar.vk answered
plz try this... select * from Problem P inner join ( SELECT xmlname.value('/Names[1]/name[1]','varchar(100)') AS Name1, xmlname.value('/Names[1]/name[2]','varchar(100)') AS Name1 FROM ( SELECT Demand, CONVERT(XML,' ' + REPLACE(Demand,',', ' ') + ' ') AS xmlname FROM Appl )tmp)Demand_Parser on Demand_Parser.Name1 = P.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.