Salim_sam
asked on
Linked Server - Error 7405: Heterogeneous queries
Hi,
I am not sure hot to fixed this. When I run my query from Query Analyzer it works, but If I paste this query in the Stored Procedure, I get following error.
Microsoft SQL-DMO (ODBC SQLState: 42000)
Error 7405: Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
I am not sure hot to fixed this. When I run my query from Query Analyzer it works, but If I paste this query in the Stored Procedure, I get following error.
Microsoft SQL-DMO (ODBC SQLState: 42000)
Error 7405: Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
ASKER
Can please explaine little clearer or give an example?
CREATE procedure Test
as
SET ANSI_NULLS ON
EXEC ('SELECT COUNT(*) FROM XX.YY.DBO.TABLE1')
GO
wHEN i EXECUTE THIS from query analyzer I still get an error
Server: Msg 7405, Level 16, State 1, Line 1
Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
Thank you
CREATE procedure Test
as
SET ANSI_NULLS ON
EXEC ('SELECT COUNT(*) FROM XX.YY.DBO.TABLE1')
GO
wHEN i EXECUTE THIS from query analyzer I still get an error
Server: Msg 7405, Level 16, State 1, Line 1
Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
Thank you
You do the Set before executing the Create Procedure. This, for example, should work:
SET ANSI_NULLS ON
SET ANSI_WARNINGS ON
CREATE PROCEDURE MYPROC()...
SET ANSI_NULLS ON
SET ANSI_WARNINGS ON
CREATE PROCEDURE MYPROC()...
ASKER
set ANSI_NULLS ON
SET ANSI_WARNINGS ON
CREATE procedure Test
as
EXEC ('SELECT COUNT(*) FROM XX.YY.DBO.TABLE1')
go
It doesn't accept this proc. I can't place on the top these statements
SET ANSI_NULLS ON
SET ANSI_WARNINGS ON
Can you send me NorthWind db sample procedure that works?
Thank you
SET ANSI_WARNINGS ON
CREATE procedure Test
as
EXEC ('SELECT COUNT(*) FROM XX.YY.DBO.TABLE1')
go
It doesn't accept this proc. I can't place on the top these statements
SET ANSI_NULLS ON
SET ANSI_WARNINGS ON
Can you send me NorthWind db sample procedure that works?
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much
The ANSI_WARNINGS state is determined by the current setting when the procedure is executed. The ODBC Driver and OLE DB Provider automatically set this ON by default.