Wednesday, March 21, 2012

Error 7405 with a linked server and stored procedure

I'm trying to create a stored procecudure using the openquery command to an linked ODBC server.

Everytime I try to save the procedure I get "error 7405: Heterogenous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection."

I've checked everywhere and set these options on, yet it still doesn't work.

Any ideas?

It's a simple procedure and when I type the sql into query analyzer it works.

HELP?

Here is the procedure.
===============================
CREATE PROCEDURE [dbo].[stpDKLink] AS

select * from openquery(dk, 'select * from pub.invoice')

GO
===============================Yes, SQLServer error message is a bit misleading in this case. Try this out:

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].[stpDKLink] AS
select * from openquery(dk, 'select * from pub.invoice')
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GOsql

No comments:

Post a Comment