gpt4 book ai didi

tsql - 在 Azure SQL 数据仓库中找不到数据类型 'ntext' 错误

转载 作者:行者123 更新时间:2023-12-05 03:58:28 25 4
gpt4 key购买 nike

我正在使用 pyodbc 针对 Azure SQL 数据仓库运行更新语句:

cursor.execute(
"UPDATE dbo.test SET desc = ? WHERE id = ?", desc, id
)

当 desc 值很简单时,这很好用。但是当 desc 的值更复杂(更长的文本)时,执行上面的代码会出现以下错误:

pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]104220;
Cannot find data type 'ntext'. (100000) (SQLExecDirectW)")

我以为转义会解决任何问题,但事实并非如此。有什么想法/见解吗?

最佳答案

你能试试这个吗:

cursor.execute(
"UPDATE dbo.test SET desc = CAST(? AS NVARCHAR(MAX)) WHERE id = ?", desc, id
)

我猜 pyodbc 以某种方式将大字符串转换为 ntext

如果这没有帮助,请检查以下 github link - 它可能对您有所帮助,因为它解释了如果:

you're using an old SQL Server (WDAC) driver which treats nvarchar as ntext and that's why you're experiencing the issue because there's no reference to ntext type inside django-pyodbc-azure

关于tsql - 在 Azure SQL 数据仓库中找不到数据类型 'ntext' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57917296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com