Willy
Willy

Reputation: 10648

Calling a stored procedure from another SQL Server Database Engine

From SQL Server Management Studio I have connected to an SQL Server database engine. This database engine has a lot of databases. From a store procedure defined in a database I am trying to call a store procedure in another database that it is in another SQL Server database engine. So I have done:

exec [MyDatabaseEngine].[MyDatabase].[MyStoreProcedure] param1, param2

But it is not working.

I do not know if I have explained it correctly. If not, please let me know.

Upvotes: 0

Views: 16966

Answers (2)

Raghu Ariga
Raghu Ariga

Reputation: 1129

You need to have linked server created with credentials access to the other database. More info

https://learn.microsoft.com/en-us/sql/relational-databases/linked-servers/create-linked-servers-sql-server-database-engine

Once you have it, you can run queries on another server

SELECT name FROM [SRVR002\ACCTG].master.sys.databases ;  
GO 

Upvotes: 2

Sean Lange
Sean Lange

Reputation: 33571

You are missing the schema. The format is [LinkServer].[Database].[Schema].[Object]

Upvotes: 3

Related Questions