Problem with odbc and Sql Server

Andrew MacIntyre andymac at bullseye.apana.org.au
Sun May 21 09:06:23 EDT 2006


Frank Millman wrote:

> Assume a table 't1' with a column 'c1' of type varchar(10).
> 
>>From Python, set c1 to an empty string -
>     cur.execute("UPDATE t1 SET c1 = ?",[''])
> 
> The result is that c1 is actually set to a string of 10 spaces.
> 
> If I execute the command without using parameters -
>     cur.execute("UPDATE t1 SET c1 = ''")
> 
> it works - c1 is set to an empty string.
> 
> I am using Windows Server 2003 (SP1), Sql Server 2000 (SP4), and ODBC
> Driver 2000.86.1830.00.

You might want to test with mxODBC, to see whether the problem is with
the odbc module or something further down the stack. Given that it works
with the MS-Jet (Access) ODBC provider (odbc interface), but not with 
the SQL Server provider, I'd say that the problem is more probably outside
the control of the odbc module.

I've not had much to do with SQL Server, but I wonder whether there is
some configuration setting that might be affecting this behaviour.

-------------------------------------------------------------------------
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au  (pref) | Snail: PO Box 370
        andymac at pcug.org.au             (alt) |        Belconnen ACT 2616
Web:    http://www.andymac.org/               |        Australia



More information about the Python-list mailing list