David Tunnell
David Tunnell

Reputation: 7532

Can't create stored procedure with reference to table in other database

I have some databases on Azure SQL v12. One is named GM_STAGE and one STRAT_CMS.

I am trying to add this stored procedure to STRAT_CMS:

CREATE PROCEDURE [dbo].[SP_GM_STAGE_FILE_LOAD_STS_GET]
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    SELECT *
    FROM [GM_STAGE].[dbo].[FILE_LOAD_STATUS]

END

I am getting this error which I don't understand because the database clearly exists.

Reference to database and/or server name in 'GM_STAGE.dbo.FILE_LOAD_STATUS' is not supported in this version of SQL Server.

enter image description here

Why can't I create this stored procedure?

Upvotes: 0

Views: 372

Answers (1)

Richard
Richard

Reputation: 21

Cross database queries are supported in Azure SQL v12. Make sure that both databases you are using are up to date.

https://azure.microsoft.com/en-us/blog/querying-remote-databases-in-azure-sql-db/

Upvotes: 2

Related Questions