views:

116

answers:

2

I want to call a sproc on server B from server A in TSQL without linking the servers. Is it possible to use something like a connection string to execute this sproc? The return will be a single nvarchar value.

Regards.

A: 

i know of no way of doing it without ...

  1. creating an extended stored proc to do it for you
  2. perhaps using xp_cmdshell to use isql to execute your stored proc .. however, getting the result might be tricky (perhaps write the result to a table on your current server in the same sql file that isql is reading)

-don

Don Dickinson
+5  A: 

To avoid "linked servers", you'd normally use OPENDATASOURCE

After comment:

EXEC OPENDATASOURCE('SQLNCLI', 'Data Source=London\Payroll;Integrated Security=SSPI').remoteDB.remoteSchema.remoteProc @param1, @param2,...

Simple 4 part naming convention. The whole OPENDATASOURCE simply replaces the linked server name...

Note: you may have issues with "adhoc access"

gbn
+1 but there should be a triple bonus score if you can provide an example of it using a sproc, since msdn doesn't give one
Nick Kavadias
@Nick: bring it on... ;-)
gbn
Nick Kavadias
@Nick: I've edited so you can upvote again if you like...
gbn