title: How to join tables in different database on the same Sybase server
body: <p>Am working on Sybase ASE 15.5.</p>
  
  <p>I have 2 databases created in the same server, "DatabaseA" and "DatabaseB". The database owner is "User".</p>
  
  <p>Logging in as "User" I created a table in "DatabaseB", called "TableA".</p>
  
  <p>Now, my user has access to both database, but the default database is "DatabaseA".</p>
  
  <p>This is sucessful when i login to DatabaseA:</p>
  
  <pre><code>USE DatabaseB
  GO
  SELECT * from DatabaseB.User.TableA
  GO
  </code></pre>
  
  <p>But this is not:</p>
  
  <pre><code>USE DatabaseA
  GO
  SELECT * from DatabaseB.User.TableA
  GO
  </code></pre>
  
  <p>It tells me that there is "No such object or user exists in the database".</p>
  
  <p>I have Googled and most sites say that if the user has rights, then you only need to append the database and owner name to the table to access it. But it does not seems to work for my case.</p>
  
  <p>I have tried creating a non DBO user "User2", and assigning it select rights using</p>
  
  <pre><code>GRANT SELECT ON DatabaseB.User.TableA to User2
  </code></pre>
  
  <p>and sp_helprotect shows that the rights is there for this user. But the results are exactly the same as when i query it with User.</p>
  
  <p>Below is the result from sp_helprotect</p>
  
  <pre><code>grantor | grantee | type    | action   | object   | column | grantable
  'User'  | 'User2' | 'Grant' | 'Select' | 'TableA' | 'All'  | 'FALSE'
  </code></pre>
  
  <p>Is there anything configuration or setting that needs to be checked to enable this?</p>
  
  <p><strong>EDIT (22 July 2015)</strong></p>
  
  <p>Just discovered something. There are a few tables with DatabaseB that i can access from DatabaseA, but not all tables.</p>
  
  <p>For example, there is TableA, TableB, TableC, and TableD in DatabaseB. Out of which TableB and TableD can be queried from DatabaseA using </p>
  
  <pre><code>USE DatabaseA
  GO
  SELECT * from DatabaseB.User.TableB
  GO
  SELECT * from DatabaseB.User.TableD
  GO
  </code></pre>
  
  <p>which is sucessful. And </p>
  
  <pre><code>USE DatabaseA
  GO
  SELECT * from DatabaseB.User.TableA
  GO
  SELECT * from DatabaseB.User.TableC
  GO
  </code></pre>
  
  <p>fails.</p>
  
  <p>Help!!!</p>