继续阅读之前,我们假设您熟悉以下知识:
n Python / PHP
n SQL Server 2000 SP4以上版本的Microsoft sql server
n pymssql
n NTEXT类型
本文讨论了在Python中,如果利用pymssql来连接Microsft Sql server 2000 SP4以上版本数据库查询NTEXT类型数据,如何成功返回数据。
在PHP中类似问题也可以这么解决。
关键词: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library。 表象: 如果你的sql server 2000 sp4以上版本的数据库中有一个字段是NTEXT类型,那么当你使用pymssql来做查询的时候,您可能得到如下错误:
错误日志
MS SQL message: ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. (severity 16)
_mssql.error: SQL Server message 4004, severity 16, state 1, line 1: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.
It's the SQL Server complaining that it doesn't support pure Unicode via TDS or older versions of ODBC. There's no fix for this error. A workaround is to change the column type to NVARCHAR (it doesn't exhibit this behaviour), or plain TEXT.