How to concatenate multiple rows into single string or single row

- using sTRING_AGG function


The STRING_AGG function is available from sql server 2017 onwards.The STRING_AGG is a string function which will simplify the concatenation of rows.

The sysntax for using STRING_AGG function as per below.

SELECT STRING_AGG( ISNULL(Narration, ' '), ',') As Narration
       From PostedNarration


You can use comma and space between rows for concatenate.

Popular posts from this blog

How to Reset Terminal license on Windows 2008, 2008 R2 and 2012

How to remove a static IP configuration for an absent network adapter or uninstall hidden network adapter