title: How can I compare tables in two different databases using SQL?
body: <p>I'm trying to compare the schemas of two tables that exist in different databases. So far, I have this query</p>
  
  <p><code>SELECT * FROM sys.columns WHERE object_id = OBJECT_ID('table1')</code></p>
  
  <p>The only thing is that I don't know how to use the sys.columns to reference a database other than the one that the query is connected to. I tried this</p>
  
  <p><code>SELECT * FROM db.sys.columns WHERE object_id = OBJECT_ID('table1')</code></p>
  
  <p>but it didn't find anything.</p>
  
  <p>I'm using SQL Server 2005</p>
  
  <p>Any suggestions? thanks!</p>