I have a table that is several hundred columns wide. Is there a way to convert each row into a single concatenated string with the column title included without having to list each single column in the query?
I'm doing this because the columns represents fields in an event report. I'm putting them back together so a person can read the report in a logical manner.
I've done some of this with a query, but it is laborious to do for each column and seems error-prone.
Here is a brief snippet showing three columns concatenated in the format I need, done in the column-by-column approach:
SELECT Concat( IIf(Id IS NULL, Null, Concat('Id: ' , [Id] , '\n') ) , IIf(StandardClientId IS NULL, Null, Concat('StandardClientId: ' , [StandardClientId] , '\n') ) , IIf(ClientName IS NULL, Null, Concat('ClientName: ' , [ClientName] , '\n') ) ) AS ReportLine FROM dbo.DataDecoded;