Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Executing a Stored Procedure against a Linked server (W/O ..

 
   Database Help (Home) -> Server RSS
Next:  No display of Linked Table Mgr  
Author Message
robboll

External


Since: Jan 15, 2008
Posts: 47



(Msg. 1) Posted: Wed Apr 20, 2011 11:25 am
Post subject: Executing a Stored Procedure against a Linked server (W/O putting the
Archived from groups: microsoft>public>sqlserver>server (more info?)

SQL Server 2005
Primary (HOST) Server: SERVER_A
Linked Server: SERVER_B
Linked Server: SERVER_C


I have successessfully linked SERVER_B and SERVER_C to Host SERVER_A

SERVER_A and SERVER_B have a stored procedure in Master Database
called: usp_mySP

From Host SERVER_A I can run this statement successfully against
SERVER_B:
EXEC SERVER_B.master.dbo.usp_mySP

When I run it against SERVER_C I get this message:
Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'master.dbo.usp_mySP.

How can I run the statement: EXEC SERVER_C master.dbo.usp_mySP without
putting usp_mySP on SERVER_C?

Thanks in Advance!

RBollinger

 >> Stay informed about: Executing a Stored Procedure against a Linked server (W/O .. 
Back to top
Login to vote
Erland Sommarskog2

External


Since: May 30, 2004
Posts: 2061



(Msg. 2) Posted: Wed Apr 20, 2011 6:26 pm
Post subject: Re: Executing a Stored Procedure against a Linked server (W/O putting the sp on the Linked Server) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

robboll ( ) writes:
> How can I run the statement: EXEC SERVER_C master.dbo.usp_mySP without
> putting usp_mySP on SERVER_C?

You can't.

I'm a little curious why you even expect this to be possible. The
procedure does not exist, so how would you be able to execute it?

Yes, there is one in server_A and one in server_B. And there is
a Statue of Liberty in New York and one in Las Vegas. Now you are
asking the question "how do to I get to the Statue of Liberty in
Seattle?"




--
Erland Sommarskog, SQL Server MVP, esquel.RemoveThis@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

 >> Stay informed about: Executing a Stored Procedure against a Linked server (W/O .. 
Back to top
Login to vote
Jeroen Mostert

External


Since: Oct 08, 2009
Posts: 8



(Msg. 3) Posted: Thu Apr 21, 2011 2:26 am
Post subject: Re: Executing a Stored Procedure against a Linked server (W/O putting [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2011-04-20 23:37, Erland Sommarskog wrote:
> Yes, there is one in server_A and one in server_B. And there is
> a Statue of Liberty in New York and one in Las Vegas. Now you are
> asking the question "how do to I get to the Statue of Liberty in
> Seattle?"
>
By going to Alki Beach Park. Smile

If only stored procedures were as widely replicated.

--
J.
 >> Stay informed about: Executing a Stored Procedure against a Linked server (W/O .. 
Back to top
Login to vote
robboll

External


Since: Jan 15, 2008
Posts: 47



(Msg. 4) Posted: Thu Apr 21, 2011 8:06 am
Post subject: Re: Executing a Stored Procedure against a Linked server (W/O putting [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Well I thought it is possible to execute stored procedure usp_mySP on
SERVER_A against SERVER_C since all it's doing is querying the system
tables on SERVER_C.

I mean, If I can run from SERVER_A: Select * from SERVER_C.
[SERVER_C_DB].DBO.SERVER_C_TABLE

why cant it get that syntax from the stored procedure. It's
essentially doing the same thing?

I really thought this was possible.


On Apr 20, 4:37 pm, Erland Sommarskog wrote:
> robboll ( ) writes:
> > How can I run the statement: EXEC SERVER_C master.dbo.usp_mySP without
> > putting usp_mySP on SERVER_C?
>
> You can't.
>
> I'm a little curious why you even expect this to be possible. The
> procedure does not exist, so how would you be able to execute it?
>
> Yes, there is one in server_A and one in server_B. And there is
> a Statue of Liberty in New York and one in Las Vegas. Now you are
> asking the question "how do to I get to the Statue of Liberty in
> Seattle?"
>
> --
> Erland Sommarskog, SQL Server MVP, esq... RemoveThis @sommarskog.se
>
> Links for SQL Server Books Online:
> SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
> SQL 2005:http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
 >> Stay informed about: Executing a Stored Procedure against a Linked server (W/O .. 
Back to top
Login to vote
Gene Wirchenko

External


Since: Oct 31, 2006
Posts: 177



(Msg. 5) Posted: Thu Apr 21, 2011 11:42 am
Post subject: Re: Executing a Stored Procedure against a Linked server (W/O putting the sp on the Linked Server) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Wed, 20 Apr 2011 23:37:39 +0200, Erland Sommarskog
wrote:

>robboll ( ) writes:
>> How can I run the statement: EXEC SERVER_C master.dbo.usp_mySP without
>> putting usp_mySP on SERVER_C?
>
>You can't.
>
>I'm a little curious why you even expect this to be possible. The
>procedure does not exist, so how would you be able to execute it?
>
>Yes, there is one in server_A and one in server_B. And there is
>a Statue of Liberty in New York and one in Las Vegas. Now you are
>asking the question "how do to I get to the Statue of Liberty in
>Seattle?"

I can not believe you missed such an easy one:
ren "Space Needle" "Statue of Liberty"
-- although you might have to suffix with a number -- and retry. <BEG>

Sincerely,

Gene Wirchenko
 >> Stay informed about: Executing a Stored Procedure against a Linked server (W/O .. 
Back to top
Login to vote
Erland Sommarskog2

External


Since: May 30, 2004
Posts: 2061



(Msg. 6) Posted: Thu Apr 21, 2011 6:25 pm
Post subject: Re: Executing a Stored Procedure against a Linked server (W/O putting the sp on the Linked Server) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

robboll ( ) writes:
> Well I thought it is possible to execute stored procedure usp_mySP on
> SERVER_A against SERVER_C since all it's doing is querying the system
> tables on SERVER_C.
>
> I mean, If I can run from SERVER_A: Select * from SERVER_C.
> [SERVER_C_DB].DBO.SERVER_C_TABLE
>
> why cant it get that syntax from the stored procedure. It's
> essentially doing the same thing?
>
> I really thought this was possible.

The call

EXEC Server_C.master.dbo.usp_mySP

works if there is a usp_mySP in the master database on Server_C. But if
there is not, the call fails.

The statement

SELECT * FROM Server_C.master.dbo.some_table

works if there is a table some_table in master database on Server_C,
but if there is not, it fails.

So, yes, they are the same.

You can of course write a stored procedure on Server_A which accesses data
on Server_C:

CREATE PROCEDURE my_sp AS
SELECT * FROM Server_C.master.dbo.some_table

But that was not how I interpreted your initial question.

I'm still uncertain what you really want to do. Maybe you could take one
step to the beginning, and explain what you are trying to achieve.

--
Erland Sommarskog, SQL Server MVP, esquel.TakeThisOut@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
 >> Stay informed about: Executing a Stored Procedure against a Linked server (W/O .. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
problem in executing extended stored procedure - Hi ll, When i am trying to execute extended stored procedure im getting error as: Msg 22048, Level 15, State 0, Line 0 Error executing extended stored procedure: Invalid Parameter Can u guys help me out

Stored Procedure reduced performance in SQL server 2005 - Hello All, I have a problem regarding stored procedure execution. Recently we migrated from SQL Server 2000 to 2005 and our application from .Net Framework 1.1 to 3.5. We have a stored procedure which returns search results on execution given some..

SQL Server 2005 - Performance - Writing stored procedure i.. - I have a stored procedure which is having multiple cursors. These cursors are affecting the performance of SP. With SQL Server 2005 we can write the SP in C#. If I replace those cursors with for/while loop of C# code then will there be any performanc...

Executing an extended stored proc from within a function! - Hi folks, I've just developed an extended stored procedure in .net framework. It's being added to the SQL Server 2005, and it's executed properly. Now, I've got a user defined function as follows: CREATE FUNCTION [dbo].[GetItems]() RETURNS @reports..

How to get Procedure call text from within SQL Stored Proc.. - Hi, I'm using SQL Server 2005. I have implemented some SPs with the TRY..CATCH structure and each time that I have an error, I just log it into a dedicated LogError table. I would like to add in LogError a column containing the command that was used by....
   Database Help (Home) -> Server All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]