Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old July 28th, 2003, 12:48 PM
justastef justastef is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 16 justastef User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Stored Procedure

I am logged into server1 and need to perform a remote query on server2. This query needs to be located in a stored procedure. I have created the procedure... this is not the issue. The issue is executing the procedure. In order to perform a remote query, I need to set ansi_nulls and ansi_warnings to on. By default, these are always off. Below is the code for the procedure.


Create procedure procedure1 as
Select * from Server2.Database2.dbo.RemoteTable

Procedure was created in Enterprise Manager and will be edited in Enterprise Manager. Query analyzer is not an adequate resource to execute this procedure (and despite that, everything that is executed in QA tends to work in itself and nowhere else).

I need to enable WITHIN the stored procedure Ansi_nulls and Ansi_warnings to ON... I have attempted many different ways to do this. I have tried all of the following:

SET ANSI_NULLS ON
SET ANSI_WARNINGS ON
GO
Create procedure procedure1 as
Select * from Server2.Database2.dbo.RemoteTable

(error msg: create procedure must be the first statement in procedure)

Create procedure procedure1 as
Set ansi_nulls on
set ansi_warnings on
Select * from Server2.Database2.dbo.RemoteTable

(error msg: you must enable ansi_nulls and ansi_warnings)

Create procedure procedure1 as
Set ansi_nulls on
set ansi_warnings on
go
Select * from Server2.Database2.dbo.RemoteTable

(error msg: go is to indicate end of procedure)

There must be a way around this... The reason that these options need to be enabled WITHIN the procedure itself is because it is going to execute automatically; no one will be able to manually set these options and manually execute this procedure... basically it is for automation purposes. I have attempted using T-SQL code in a job to enable these prior to executing the stored procedure which will not work as well. I am assuming the problem as to setting these options in the procedure is because it requires a GO in order to actually enable these on the connection level, however, GO in a stored procedure means the end unlike in just a sql editor.

Reply With Quote
  #2  
Old July 28th, 2003, 09:16 PM
MattR MattR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: High above the mucky-muck (Columbus, OH)
Posts: 266 MattR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to MattR
The second method is definitely the way to go. What is the exact error message and the exact T-SQL? Often when the code is paraphrased something small slips through the cracks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Stored Procedure


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway