How to connect to one database from another database

  • Hi ,
    I have a stored procedure SP1 in database DB1 , schema SCH1.
    From within this  SP1,   a table TB2(under schema SCH2)  of another database DB2 is queried(a simple select statement).
    (select * from  DB2.SCH2.TAB2...  where  --condition--).

    Now if a user USER1 has access to only DB1 and not DB2 (because DB2 access should not be given to USER1 as per some rules).

    When USER1 executes SP1 , error is thrown.. "  USER1 is not able to access the database 'DB2' under the current security context."

    Without given extra privileges to USER1 , are there any proper ways to execute SP1?

    -MJ

  • Please check out EXECUTE AS in the SQL Server documentation.

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

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