|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Stored Procedure |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|