title: Run Stored Procedure From Another Database in Current Database
body: <p>I have one <code>shared</code> database and multiple <code>client</code> databases.  The data is stored in the <code>client</code> database.  We want to create a master set of stored procedures in the <code>shared</code> database and execute them from the <code>client</code> database.  Given the following:</p>
  
  <pre><code>use shared;
  go
  create procedure GetInvoices as
    print db_name() ' &lt;- current database'
    select * from invoices
  go
  
  use client1;
  create table invoices(...columns...)
  exec shared.dbo.GetInvoices
  </code></pre>
  
  <p>This returns the following error:</p>
  
  <pre><code>shared &lt;- current database
  Msg 208, Level 16, State 1, Procedure GetInvoices, Line 3
  Invalid object name 'invoices'.
  </code></pre>
  
  <p><strong>Without</strong> using dynamic SQL, how can I run the stored procedure in <code>shared</code> from <code>client1</code> so that it executes in <code>client1</code> and thus has access to all of the tables in <code>client1</code>?</p>