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];
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
plz try this... select * from Problem P inner join ( SELECT xmlname.value('/Names/name','varchar(100)') AS Name1, xmlname.value('/Names/name','varchar(100)') AS Name1 FROM ( SELECT Demand, CONVERT(XML,' ' + REPLACE(Demand,',', ' ') + ' ') AS xmlname FROM Appl )tmp)Demand_Parser on Demand_Parser.Name1 = P.