I created an application to send mail to users.
I’m using a database where some users have more than one email address assigned.
Name Mail
-----------------------------------------
BusinessXPTO mail1@xpto.com;mail2@xpto.com
The email column can contain more than one email, separated by a semicolon.
I want to split the string so I can put each email on a different line.
Name Mail
-----------------------------------------
BusinessXPTO mail1@xpto.com
BusinessXPTO mail2@xpto.com
What is the best solution?
Thanks
Here’s a simple example using the XML features in SQL Server 2005 and above. I’ve taken it verbatim from here but there are lots of examples if you google “split string sql server xml”
There are other solutions with cursors but this approach as worked well for me.