how to use a table from diff DB in an SP?

  • Hi, first timer here.

    I inherited a SP from my IT vendor who set up the SQL database for my company.

    This is an example of the SP created by our vendor:

    USE [sqldbONE]

    GO

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER PROCEDURE [dbo].[SP_PATCH_DIM]

    AS

    DECLARE ....{variables}

    BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON;

    DECLARE CUR_POLICY CURSOR FOR

    SELECT COLUMN1, COLUMN2, COLUMN3

    FROM TABLE2

    ORDER BY COLUMN1;

    ....

    The thing is that TABLE2 is NOT in sqldbONE. It is in another DB (sqldbTWO) in the same server.

    My question is that how do you go about not needing to have the 'sqldbTWO.dbo.TABLE_2' in that SP since it did not hit any error when I run it?

    I hope this make sense for you to give me an answer. Do let me know if you need more information since I am still new to this.

    Thank you.

  • Quite possibly with the use of a Synonym in the database.

    ...

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply