[freetds] Inserting empty strings into MS SQL Server

Joseph Geiser joe at mail.paravisions.com
Mon Aug 9 14:06:17 EDT 2004

Charles Bearden writes,

> I am trying to avoid NULLs in my columns and am finding that the empty
> string works as a substitute for almost all cases where I would have
> used a NULL in the past.  However, when I pass empty strings as values
> in the tuple second argument to the execute method (e.g.
> 'cu.execute(stmnt, tpl)'), the following exception is raised:

Not knowing the data types you are passing, here is something to keep in

Numeric data can be NULL in SQL Server, and passing a NULLable value to a
numeric column is permitted.  What is NOT permitted however, is passing an
empty string to a numeric column, and this looks like what might be
occurring here.

Check data types - and if you must use something other than NULL in
numerics, and we do not permit it here, we use Defaults - default all
numerics to zero or other value that would make sense.  For Dates, we do not
use null dates - we either default to getdate() (current date/time) or for
an undefined date, we use '2100-12-31 00:00:00' - well enough into the
future that this system will very well be replaced by then.


Joe Geiser

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 2256 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20040809/6c6a5dd8/attachment.bin 

More information about the FreeTDS mailing list