0

Here's my screenshot: How can I rewrite this query to display a single record but have all four "ColumnName" data fields in a single field?

So basically, I'm after a single row that looks like:

TableName: 20180301_Vitality

ColumnData: _CustomObjectKey | Email address | Subscriber key | opCoCode 2

enter image description here

Mike Marks
  • 10,017
  • 17
  • 69
  • 128
  • 1
    Google: SQL Server string aggregation. – Gordon Linoff Apr 27 '18 at 02:06
  • Refer here: https://stackoverflow.com/questions/451415/simulating-group-concat-mysql-function-in-microsoft-sql-server-2005 – Pham X. Bach Apr 27 '18 at 02:09
  • Thank you @GordonLinoff, however I'm running SSMS 2016 and I believe this is a function new to 2017 and newer, unfortunately. It does however appear to be exactly what I need, but I cannot use it. – Mike Marks Apr 27 '18 at 13:55

1 Answers1

0

You can use SQL Server's (2005 or newer) STUFF function.

https://learn.microsoft.com/en-us/sql/t-sql/functions/stuff-transact-sql?view=sql-server-2017

Z .
  • 12,657
  • 1
  • 31
  • 56