x

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];
more ▼

asked Dec 04, 2017 at 09:06 PM in Default

avatar image

klemmyjb
0

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

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

more ▼

answered Dec 05, 2017 at 08:50 AM

avatar image

anthony.green
3.1k 1 4 6

(comments are locked)
10|1200 characters needed characters left

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.

more ▼

answered Jan 03 at 02:07 PM

avatar image

sajikumar.vk
1 1

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x411

asked: Dec 04, 2017 at 09:06 PM

Seen: 54 times

Last Updated: Jan 03 at 02:07 PM

Copyright 2018 Redgate Software. Privacy Policy