WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

STRING_AGG aggregation result exceeded the limit of 8000 bytes. Use LOB types to avoid result truncation. #21929

@DaveNelms

Description

@DaveNelms

i.is_disabled, STRING_AGG(c.name, ',') AS column_names

Our environment contains tables with over 400 columns that have column name lengths of 20 to 100 characters. In our case, the string length was 16,091 characters in one database. This causes the STRING_AGG() function to throw the error: STRING_AGG aggregation result exceeded the limit of 8000 bytes. Use LOB types to avoid result truncation.

To solve here, cast the column name to nvarchar(max) -> STRING_AGG(cast(c.name as nvarchar(max), ',')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions