[freetds] error with freetds, python and Sql Server 2003

James K. Lowden jklowden at freetds.org
Tue Apr 4 22:07:41 EDT 2006


Erik Myllymaki wrote:
> In particular, it i the size of the python strings to be inserted that
> causes  the errors:
> 
> inserting string <= 255 characters into a MSSQL VARBINARY(8000) field
> works
> 
> inserting string of length 256 characters into a MSSQL VARBINARY(8000)
> errors with:
> 	mx.ODBC.Error.Warning: ('22001', 8152, '[unixODBC][FreeTDS][SQL
> 	Server]String 
> or binary data would be truncated.', 6083)

It's a little hard for us to tell what's happening, because it's not clear
what Python is asking of FreeTDS.  I'd like to know what datatype Python
is presenting your data as, i.e. how it's binding its data.  It looks like
it's asking for a binary binding.  That would explain why you get
"varbinary is incompatible with text".  

First of all, are you using TDS 7.0 or 8.0?  You should be.  The top of
your TDSDUMP log will tell you.  

Second, I bet you'll find that 'data would be truncated' message in your
TDSDUMP log, too.  It would be interesting to see that line and the 200 or
so lines around it.  

HTH.

--jkl


More information about the FreeTDS mailing list