Reputation: 133
I have 2 databases db1 and db2 in azure.And db1 is having stored procedure stored_p1,db2 is having stored procedure stored_p2. I need to call stored_p1 from stored_p2. For calling table from another database i have used external tables. for storedprocedure, do i need to use anything like external table
Upvotes: 1
Views: 5456
Reputation: 121
Old question but it was still relevant to me. Here is my solution (in my case I am connecting between two different database servers):
CREATE DATABASE SCOPED CREDENTIAL DB1Credential
WITH IDENTITY = 'DB1_User',
SECRET = 'DB1_Password';
CREATE EXTERNAL DATA SOURCE DB1Server WITH
(TYPE = RDBMS,
LOCATION = 'your-db1-server-reference',
DATABASE_NAME = 'db1',
CREDENTIAL = DB1Credential,
) ;
EXEC sp_execute_remote
N'DB1Server',
N'stored_p1'
Parameters can also be included as defined here: https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-execute-remote-azure-sql-database?view=azuresqldb-current
Upvotes: 2
Reputation: 481
This requires elastic database queries. Consider using the cross-database functionality documented here: https://azure.microsoft.com/en-us/documentation/articles/sql-database-elastic-query-vertical-partitioning/.
It also provides for a function called sp_execute_remote which takes a shardmap name and a T-SQL query as its input.
Upvotes: 1
Reputation: 5876
This seems to require elastic
database queries, potentially with the SP_ EXECUTE_FANOUT
command.
Remote stored procedure calls or remote functions invocations that use sp_execute_fanout can now use parameters similar to sp_executesql.
Options without sharding are still apparently "in the works" last I heard.
Upvotes: 2