FreeTDS/unixODBC UPDATE failed because the following SET options have incorrect settings: 'CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING'

StackOverflow https://stackoverflow.com/questions/18276471

Pergunta

I have a stored procedure that has an update to a table with a computed persisted column. When running the stored procedure from Management Studio it works fine. But when I run it with unixODBC isql I get this error

[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.

I also get this error message from within Management Studio if I put the following in my stored procedure:

SET ANSI_PADDING OFF
SET ANSI_WARNINGS OFF

I tried setting these to "ON" in the stored procedure but that did not work.

I also tried adding

AnsiNPW = 1

in my unixODBC data-source template.

I even tried recreating the stored procedure with those ANSI_PADDING and ANSI_WARNINGS set to ON before the CREATE PROCEDURE clause.

Nothing though seems to make a difference.

Any suggestions are appreciated

Foi útil?

Solução

Looking into this further, MSDN says about SET statements in stored procedures

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.

So this explains why setting them in the stored procedure did nothing.

To get around this I set them before calling my stored procedure like so:

SET CONCAT_NULL_YIELDS_NULL, ANSI_PADDING, ANSI_WARNINGS ON; EXEC myProc ...
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top