Concatenate Row Results Sql Php

ResultsConcatenate Row Results Sql Php

Concatenate Row Results Sql Php Download

I have a table with 2.6m records. It looks like this: email prjectnamerafael.nadal@xyz.com lab1rafael.nadal@xyz.com lab2rafael.nadal@xyz.com lab3TEST@TEST.COM shift1TEST@TEST.COM shift2But I want my table to look like this: email projectnamerafael.nadal@xyz.com lab1, lab2, lab3TEST@TEST.COM shift1, shift2, shift3I have used this query select distinct email,STUFF((Select ','+projectnamefrom dbo.UMG sent 2016 as T1where T1.email=T2.emailFOR XML PATH(')),1,1,') from dbo.UMG sent 2016 as T2;It has been running for 5 hours already.How do I speed up the process? That STUFF FOR XML PATH string concatenation technique sure is cute, but it does not scale very well and across millions of rows it is probably not a very good idea.

Sql Concatenate Results Into String

In this article we will show you, How to write a SQL Query to Concatenate Rows in SQL Server to form a String with example. This is one of the common SQL Interview Question that you might face in the interviews. For this sql server concat rows example, We are going to use the below shown data Above. Concatenate query results in SQL Server using Coalesce. If you want to concatenate the result of a query and display it in a single row, you can use COALESCE. We will concatenate results of this query: USE AdventureWorks SELECT AddressID.

Posted on  by  admin