none
Concatenate values from multiple rows to a variable

    Question

  • I have multiple years in rows e.g.

    2018

    2017

    2016

    I want to concatenate and assign to a variable like

    @allYears = "2018, 2017, 2016"

    Any pointers are helpful.

    Thursday, September 21, 2017 5:28 AM

All replies

  • I'd be happy to help.

    You can do this by doing a

    @allYears= SELECT String.Join(",",ARRAY_AGG(year)) AS allyears FROM @rows;

    however this will return a rowset which you will have to join with your other data if you want to use this as a scalar value (U-SQL doesn't support scalar select expressions).

    Thank you,

    Guy

    Wednesday, October 4, 2017 10:25 PM