Transposing one column to a row.
I've obtained a list of email addresses using the following query:
select
user_login.email_address
from
user.login with(nolock)
Example of results are as follows:
Email
--------------------
abc@helloworld.com
no_email
romeo@abc.com.au
Juliet@abc.com.au
What I would like to do is run the query, transpose and get results as Text (with semi-colons in between results), so I can automatically paste the results into an email like below:
Desired result:
abc@helloworld.com; romeo@aboc.com.au; juliet@abc.com.au
I tried to understand the PIVOT and UNPIVOT functions, but I'm just lost in how I can insert semicolons in between results. Hope someone can help. Thanks.