-
Notifications
You must be signed in to change notification settings - Fork 25
Description
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.