GROUP_CONCAT SQL Origin: Data OSI layer 7 · Application Last updated 18 Nov 2026

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).

Exact message you may see 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
Seen on: SQL MySQL SQL Server

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

  1. MySQL: SET SESSION group_concat_max_len = 1000000;
  2. SQL Server: STRING_AGG(CAST(col AS varchar(max)), ',')
  3. Aggregate in the application for very large sets

Detailed fix by platform

SQL

  1. sql
    SET SESSION group_concat_max_len = 1000000;
    SELECT STRING_AGG(CAST(name AS varchar(max)), ', ') FROM people;

How to diagnose

  1. Result — Truncated?
  2. Limit — Which setting?
  3. 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:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

1406 — MySQL ERROR 1406: Data too long for column (MySQL)14068114 — SQL Server Msg 8114: Error converting data type varchar to numeric (SQL)8114cartesian — Query returns far too many rows: accidental Cartesian product (missing JOIN condition) (SQL)cartesianCASE — CASE expression returns mixed types: conversion failed / types cannot be matched (SQL)CASECOUNT — COUNT(column) ignores NULLs: counts differ from COUNT(*) (SQL)COUNTdate format — Dates mixed up: dd/mm/yyyy vs mm/dd/yyyy, ISO 8601 recommended (SQL)date formatsorting — Numbers sort wrongly (1, 10, 2): VARCHAR column sorted as text (SQL)sortingGROUP_CON…

Explore the map of this error Full error map →

🧠 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.