简体   繁体   中英

How to select multiple email addresses from SQL query?

In an XSL webpage, I'd like to select data for sending an email to multiple addresses taken from an SQL query.

The XSL code would be something like this:

在此处输入图片说明

where "@emails" would be taken from an SQL query (querying a table column). I was thinking about creating a string: address + semicolon + space + address + semicolon + space... and so on until it runs out of email addresses.

How to do that?

You can do concatenation as:

select stuff((select '; ' + eMailColumn
from TableName
where SomeColumn = @conditionValue
    and eMailColumn is not NULL
for xml path('')), 1, 2, '')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM