我有一个存储过程,它对具有计算持久列的表进行更新。 从Management Studio运行存储过程时,它可以正常工作。但是当我用unixODBC isql运行它时,我得到了这个错误
[37000][unixODBC][FreeTDS][SQL Server]UPDATE failed because the following
SET options have incorrect settings: 'CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS,
ANSI_PADDING'. Verify that SET options are correct for use with indexed views
and/or indexes on computed columns and/or query notifications and/or xml data
type methods.
如果我在存储过程中放入以下内容,我也会从Management Studio中收到此错误消息:
SET ANSI_PADDING OFF
SET ANSI_WARNINGS OFF
我尝试在存储过程中将这些设置为“ON”,但这不起作用。
我也尝试添加
AnsiNPW = 1
在我的unixODBC数据源模板中。
我甚至尝试在CREATE PROCEDURE子句之前将那些ANSI_PADDING和ANSI_WARNINGS设置为ON来重新创建存储过程。
但似乎没什么好处。
感谢任何建议
答案 0 :(得分:2)
进一步研究,MSDN说存储过程中的SET语句
Stored procedures execute with the SET settings specified at execute time except
for SET ANSI_NULLS and SET QUOTED_IDENTIFIER. Stored procedures specifying SET
ANSI_NULLS or SET QUOTED_IDENTIFIER use the setting specified at stored procedure
creation time. If used inside a stored procedure, any SET setting is ignored.
这就解释了为什么在存储过程中设置它们没有做任何事情。
为了解决这个问题,我在调用我的存储过程之前设置它们,如下所示:
SET CONCAT_NULL_YIELDS_NULL, ANSI_PADDING, ANSI_WARNINGS ON; EXEC myProc ...