[freetds] VARCHAR values > 8000 bytes truncated (db-lib)

Joshua Lang joshua.h.lang at gmail.com
Thu Dec 10 14:02:49 EST 2015

When trying to pass stored procedure VARCHAR(MAX) parameters (using
SYBVARCHAR for the parameter type), the value is truncated at 8000. This is
due to the `tds_fix_column_size` method limiting the value to 8000 because
the `column_varint_size` of the column == 2.

Based on the comment in `tds_fix_column_size` (src/tds/query.c), it seems
as if this is unexpected:

    /* note that varchar(max)/varbinary(max) have a varint of 8 */

The comment above indicates that this should be supported. Am I missing
something or using the db-lib API incorrectly? My code is working fine

freetds: 0.95.73
OS: Ubuntu 14.04
DB: MS SQL Server 2008 SP3
TDS: 7.3



More information about the FreeTDS mailing list