Friday, February 17, 2012

Connecting a stored procedure to another server

I created a new stored procedure on one server because this is the only
server we can create new stored procedures on, however, all of my select
statements in this procedures are on a different server. How do I execute
this stored procedure on the other server, database, table, and login?Create a REMOTE Server or LINK Server, which you may not be able to do. You
can setup a Linked server to run under the context of one account.
"Ryan D" <RyanD@.discussions.microsoft.com> wrote in message
news:C749A1D6-F81F-4F50-8CDA-6681AF057BCD@.microsoft.com...
>I created a new stored procedure on one server because this is the only
> server we can create new stored procedures on, however, all of my select
> statements in this procedures are on a different server. How do I execute
> this stored procedure on the other server, database, table, and login?
>|||Andy,
I need the syntax for this please. Do you mean to use the
sp_addlinkedserver command? And then do I use the USE statement, followed b
y
the query?
"Andy Wilbourn" wrote:

> Create a REMOTE Server or LINK Server, which you may not be able to do. Yo
u
> can setup a Linked server to run under the context of one account.
> "Ryan D" <RyanD@.discussions.microsoft.com> wrote in message
> news:C749A1D6-F81F-4F50-8CDA-6681AF057BCD@.microsoft.com...
>
>|||Off the top of my head:
1. create a linked server.
2. change your select statements to have fully qualified names.
for example,
select colA, colB
from MyLinkServer.MyDatabase.dbo.MyTable
if you need to execute a stored procedure that exists on another server or
dynamic sql and it should run on that other server, exec
MyLinkServer.master.dbo.sp_executesql MySPName/@.SQL
Hope that helps,
Joe
"Ryan D" wrote:

> I created a new stored procedure on one server because this is the only
> server we can create new stored procedures on, however, all of my select
> statements in this procedures are on a different server. How do I execute
> this stored procedure on the other server, database, table, and login?
>

No comments:

Post a Comment