Skip to content

Truncation problem on wide tables #1

@hurcane

Description

@hurcane

If a table has many columns and lengthy column names, the generated select statement can be incomplete due to truncation . This leads to unpredictable errors or potentially invalid results. In my specific case, I was getting the following results:

PRINT 'Inserting values into [tblsaLocationMaster]'
Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark after the character string 'Purchas'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'Purchas'.
PRINT 'Done'

Debug mode showed the last few characters of the generated select statement were:
+ REPLACE(RTRIM([Purchas

If the truncation occurred in just the right place, the symptom could be that the command succeeds, but some of the columns are not included in the output.

Changing the @Actual_Values variable from varchar(8000) to varchar(max) resolves the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions