STRING_AGG aggregation result exceeded the limit of 8000 bytes error

Try as below

select c.id
, c.bereichsname
, STRING_AGG( CAST(j.oberbereich as nvarchar(MAX)),',') oberBereiches 
from stellenangebote_archiv j
join bereiche c on j.bereich_id = c.id
group by c.id, c.bereichsname

So the problem is the length of the concatenated string is exceeding the character limit of the result column.

So we are setting the limit to max by converting all values to “nvarchar(max)” to solve the problem.

And “STRING_AGG()” function returns what it gets.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)