Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 exec sp on another server

Author  Topic 

jtwork
Yak Posting Veteran

82 Posts

Posted - 2008-03-31 : 08:41:24
i would like to exec a sp on a different server but not sure how to do this?

DECLARE @Cmd VARCHAR(255)
DECLARE @Output INT
SELECT @Cmd = 'dtsrun /S server /N dtsname /E'
EXEC @Output = master..xp_cmdshell @Cmd


I guess im looking for something similar to the above (but not to run a package) that will let me specify which server and sp name.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-31 : 08:44:48
You need to add that server as a linked server and then use four-part syntax to execute sp on that server:

exec LinkedServer.db1.dbo.TestSP


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-31 : 12:22:36
or try with OPENROWSET
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-03-31 : 12:25:12
You have to enable Openrowset in SQL server surface area config manager.
Go to Top of Page
   

- Advertisement -