Yes, the thread is a nice history of getting rows into cells. And it’s a LONG thread, so read all the way to the bottom! Prior to SQL Serv2017, we had to use the FOR XML hack to accomplish this. If you’re on SQL 2017+, Microsoft created a T-SQL function to combine rows to columns with STRING_AGG. You must set the database compatibility level to 2017 or higher (140-150 if I recall).
@Mark_Wonsil we have 2016 installed and are using compatibility of 2014 as we had some major issues with clocking in and out when we tried to convert to 2016.
in another export that I am using, but it was very simple. This is combining multiple fields as well as multiple rows for the quote lines and part num with description, then combining that into another combination for each of the CustCnt.EMailAddresses across the past 7 days.
That KB article does NOT use either method (FOR XML or the T-SQL), but uses CTE, UnionAll, and some calculated fields to pull the values together. That’s why I was hoping that someone would be able to help me get to the next step of combining the current data across the CustCnt.EMailAddress field. I’m still trying some things related to the FOR XML and some other possible items, but nothing is working so far.
If anyone has any other suggestions, I’m still all ears. Thanks to everyone that has posted all of the helpful information already!