Putting text from a table structure into a text string

Essentially I am trying to print out a table through a method that only can take in a text string. Say I had the following table:

Column A      Column B      Column C

   Test1             Test 2            Test 3

Realistically my table is bigger than this, but I want to convert that data into a text variable. Is there an action I can use to do this? Even if it's row by row or something. I know that there is String_Join, but I believe that's only for lists and it didn't seem to be working unless I wasn't handling it properly.

Are you filling the table with data from an aggregate? If so why not simple append the strings together to form a new string. Something like "result = test1 + test2 + test3"

Greetings,

Vincent

Vincent Koning wrote:

Are you filling the table with data from an aggregate? If so why not simple append the strings together to form a new string. Something like "result = test1 + test2 + test3"

Greetings,

Vincent

The table is already formed by pulling information from a website online. There are 5 columns and up to 8 rows, so the size can vary each time.

 

Hi,


I'm not sure if this solves your problem, but you can definitely use the "FOR JSON" SQL's option to output your results to JSON and work your way from there. See:

https://docs.microsoft.com/en-us/sql/relational-databases/json/format-query-results-as-json-with-for-json-sql-server?view=sql-server-ver15


(The output structure just has a text value)


Or maybe better, use the existing json serialize libs on the returned lists.

I don't think you mentioned the desired text format, so this might not fit or need further processing.