SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Execute SP on different server
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Pete_N
Posting Yak Master

176 Posts

Posted - 06/13/2013 :  08:07:26  Show Profile  Reply with Quote
I have two SQL Servers
Server 1 SQL2008 R2
Server 2 SQL2008 R2

Is it possible for SERVER 1 to execute a stored Procedure on Server 2 and if so how?

bandi
Flowing Fount of Yak Knowledge

India
2215 Posts

Posted - 06/13/2013 :  08:21:22  Show Profile  Reply with Quote
If you had another server as linked server, then you can execute..

1) SERVER1 should have linked server connection to SERVER2...
2) from server1 you can execute procedure which is in SERVER2 by using fully qualified name (SERVER1.DBName.SchemaName.ProcedureName )

--
Chandu
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8765 Posts

Posted - 06/13/2013 :  08:28:37  Show Profile  Visit webfred's Homepage  Reply with Quote
quote:
Originally posted by bandi

If you had another server as linked server, then you can execute..

1) SERVER1 should have linked server connection to SERVER2...
2) from server1 you can execute procedure which is in SERVER2 by using fully qualified name (SERVER2.DBName.SchemaName.ProcedureName )

--
Chandu




Too old to Rock'n'Roll too young to die.
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2215 Posts

Posted - 06/13/2013 :  08:29:44  Show Profile  Reply with Quote
It was a typo.........
quote:
Originally posted by webfred

quote:
Originally posted by bandi

If you had another server as linked server, then you can execute..

1) SERVER1 should have linked server connection to SERVER2...
2) from server1 you can execute procedure which is in SERVER2 by using fully qualified name (SERVER2.DBName.SchemaName.ProcedureName )

--
Chandu




Too old to Rock'n'Roll too young to die.



--
Chandu
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8765 Posts

Posted - 06/13/2013 :  08:32:16  Show Profile  Visit webfred's Homepage  Reply with Quote
I know
quote:
Originally posted by bandi

It was a typo.........
quote:
Originally posted by webfred

quote:
Originally posted by bandi

If you had another server as linked server, then you can execute..

1) SERVER1 should have linked server connection to SERVER2...
2) from server1 you can execute procedure which is in SERVER2 by using fully qualified name (SERVER2.DBName.SchemaName.ProcedureName )

--
Chandu




Too old to Rock'n'Roll too young to die.



--
Chandu




Too old to Rock'n'Roll too young to die.
Go to Top of Page

Pete_N
Posting Yak Master

176 Posts

Posted - 06/13/2013 :  08:39:32  Show Profile  Reply with Quote
cheers guys, will try that now
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2215 Posts

Posted - 06/13/2013 :  08:46:54  Show Profile  Reply with Quote
Another method is by using Distributed query
http://blog.sqlauthority.com/2007/10/06/sql-server-executing-remote-stored-procedure-calling-stored-procedure-on-linked-server/

--
Chandu
Go to Top of Page

Pete_N
Posting Yak Master

176 Posts

Posted - 06/13/2013 :  09:05:20  Show Profile  Reply with Quote
Hi guys,

i have tried that and come up with this error

The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "SERVER 2" was unable to begin a distributed transaction

On server 1 I have a trigger

ALTER TRIGGER [dbo].[CRM_Customer_Add]
ON [dbo].[tbCBI_client]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;

DECLARE @nLicence varchar(6)
Select @nLicence = Licence from Inserted
EXEC [SERVER 2].[MYDATABASE].[dbo].[Exec_DTSXRunner] @licence = @nLicence

END


Exec_DTSXRunner fires a dtsx. If i execute Exec_DTSXRunner direct from Server 2 it works fine.
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2215 Posts

Posted - 06/13/2013 :  09:09:51  Show Profile  Reply with Quote
Refer
http://www.sqlvillage.com/Articles/Distributed%20Transaction%20Issue%20for%20Linked%20Server%20in%20SQL%20Server%202008.asp
http://social.msdn.microsoft.com/Forums/en-US/sqldatabaseengine/thread/523116d4-4c8e-43a8-abf4-e705ffaa68c8
--
Chandu

Edited by - bandi on 06/13/2013 09:13:33
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000