GROUP_CONCAT / STRING_AGG result truncated or fails (group_concat_max_len, string length limit)
An aggregated string is cut off at 1024 characters (MySQL) or fails with a size error (SQL Server STRING_AGG, 8000 bytes).
GROUP_CONCAT truncated at 1024 charactersMsg 9829 STRING_AGG aggregation result exceeded the limit of 8000 bytesSTRING_AGG result exceeded the limit of 8000 bytes. Use LOB typesGROUP_CONCAT result truncated Meaning
MySQL's group_concat_max_len defaults to 1024; raise it per session (SET SESSION group_concat_max_len = 1000000). SQL Server's STRING_AGG returns varchar(8000) unless the input is varchar(max) (cast first, error 9829 otherwise). PostgreSQL string_agg has no practical limit but the result can exceed client limits.
Common causes
- Default
group_concat_max_len= 1024 - STRING_AGG over varchar/nvarchar without MAX
- Large groups building huge strings
- Client or driver size limits
- Silent truncation unnoticed
⚡ Quick fix
- MySQL:
SET SESSION group_concat_max_len = 1000000; - SQL Server:
STRING_AGG(CAST(col AS varchar(max)), ',') - Aggregate in the application for very large sets
Detailed fix by platform
SQL
- sql
SET SESSION group_concat_max_len = 1000000; SELECT STRING_AGG(CAST(name AS varchar(max)), ', ') FROM people;
How to diagnose
- Result — Truncated?
- Limit — Which setting?
- Cast — To MAX?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in SQL
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026