When inserting data through a linked server to a varchar(max) column with a non default collation, data gets truncated randomly at around 30 characters.
The same thing does not happen with:
* non MAX varchars columns
* text columns
* nvarchar(max) columns
Changing the collation of the column to the default database collation fixes.
The repro script uses a loopback linked server, but the same results are returned with a real linked server.
Many collations are affected by the issue. I have a script that tests the behavior with all possible collations: 545 of them fail, 178 work.
I also tested different providers, including OLEDB and SQLNCLI. The same behavior was observed.
Changing the linked server's options that deal with collation does not affect the results.