title: T-SQL Check if table exists in schema
body: <p>So far I've been using the format below for creating/updating tables</p>
  
  <pre><code>IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'table_name' AND type = 'U') 
  DROP TABLE [dbo].[table_name]
  GO
  CREATE TABLE [dbo].[table_name]()
  GO
  </code></pre>
  
  <p>But recently I came across a case where two schemas have a table with the same name. How can I check if the table exists in a specific schema? Its only the part<code>SELECT 1 FROM sysobjects WHERE name = 'table_name' AND type = 'U'</code> that needs fixing, I've changed the rest to:</p>
  
  <pre><code>IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'table_name' AND type = 'U') 
  DROP TABLE [schema_name].[table_name]
  GO
  CREATE TABLE [schema_name].[table_name]()
  GO
  </code></pre>
  
  <p>My current server version is <code>2008R2</code> so I would prefer answers that also work for that version. I have many other checks is done this way so I don't really want to completely change this pattern.</p>