Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SET ANSI_NULLS ON Problem

Status
Not open for further replies.

princessk1

Programmer
Feb 28, 2002
74
CA
I have created a stored procedure that gets data from different databases on different servers. I have added the line

SET ANSI_NULLS ON
CREATE PROCEDURE [dbo].[usp_UpdateActiveLots] AS...

If I take out the line SET ANSI_NULLS ON - I get the error 7504 - Heterogeneous queries require ANSI_NULLS & ANSI_WARNINGS settings to be set for the connection.

With the line in, I get the error
ALTER PROCEDURE MUST BE THE FIRST STATEMENT IN THE QUERY BATCH

What am I missing?

Thanks
 
The clue is that the error says ALTER PROCEDURE must be the first statement in the query BATCH. A batch is defined by the GO. Try this:

SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[usp_UpdateActiveLots] AS...

-SQLBill
 
Hi princessk1

SQLBill is correct about the GO part but if you look at your error message in your post:

"Heterogeneous queries require ANSI_NULLS & ANSI_WARNINGS settings to be set for the connection."

You actually need to set ANSI_WARNINGS ON as well, so the statement should be as follows:

SET ANSI_NULLS ON
SET ANSI_WARNINGS ON
GO

CREATE PROCEDURE [dbo].[usp_UpdateActiveLots] AS...

This is a bug in Enterprise Manager in SQL 2000. Here is the link to the support article at Microsoft:


Hope this helps

John
 
Hi princessk1

One thing I forgot is that because of the Enterprise Manager bug you need to create procedures that use linked servers in Query Analyser, therefore execute the statement in my previous post in Query Analyser.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top