When I try to save the following in the report editor I get the error message Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection and it wont save.
IF object_id('sp_DBR_FindGRNLocation','P') IS NOT NULL
DROP PROCEDURE [sp_DBR_FindGRNLocation]
GO
CREATE PROCEDURE sp_DBR_FindGRNLocation @iGRN int, @iItem int
AS
BEGIN
/*
EXEC ABS.dbo.qselAllGRNItemLocationsForLocationGridByGRNNoAndItemNo @iGRN,@iItem
*/
set ansi_nulls on
set ansi_warnings on
SELECT * INTO #MyTempTable FROM
OPENROWSET(
'SQLNCLI','Server=localhost;TRUSTED_CONNECTION=YES',
'SET FMTONLY OFF; SET NOCOUNT ON; EXEC ABS.dbo.qselAllGRNItemLocationsForLocationGridByGRNNoAndItemNo 1234,0')
SELECT * FROM #MyTempTable
drop table #MyTempTable
END GO
If I move the set ansi_nulls and the set ansi_warnings statements to before the start of creating the procedure as shown below then the report editor lets me save the report OK, but when I attempt to run the report I get the same Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection error message.
IF object_id('sp_DBR_FindGRNLocation','P') IS NOT NULL
DROP PROCEDURE [sp_DBR_FindGRNLocation]
set ansi_nulls on
set ansi_warnings on
GO
CREATE PROCEDURE sp_DBR_FindGRNLocation @iGRN int, @iItem int
AS
BEGIN
/*
EXEC ABS.dbo.qselAllGRNItemLocationsForLocationGridByGRNNoAndItemNo @iGRN,@iItem
*/
SELECT * INTO #MyTempTable FROM
OPENROWSET(
'SQLNCLI','Server=localhost;TRUSTED_CONNECTION=YES',
'SET FMTONLY OFF; SET NOCOUNT ON; EXEC ABS.dbo.qselAllGRNItemLocationsForLocationGridByGRNNoAndItemNo 1234,0')
SELECT * FROM #MyTempTable
drop table #MyTempTable
END GO
Even if I have the set ansi comments in both places (prior to the procedure create statement and after it) I still get the Heterogeneous error. Any advice of where else to put them? The database is SQL Server 2005 btw.
Thanks