title: How to check if a list of tables exists in SQL Server?
body: <p>I have a list of table names and I want to check whether each one of them exists in database or not. I know how to <a href="https://stackoverflow.com/questions/167576/check-if-table-exists-in-sql-server">check if a table exists</a>, and I can union select expressions for each table name, but there must be an easier solution. This is my current code:</p>
  
  <pre><code>select 'TableName1', CASE
           WHEN EXISTS(SELECT TABLE_NAME 
                       FROM   INFORMATION_SCHEMA.TABLES
                       WHERE  TABLE_NAME = 'TableName1') THEN 1
           ELSE 0
           end
  union
  select 'TableName2', CASE
           WHEN EXISTS(SELECT TABLE_NAME 
                       FROM   INFORMATION_SCHEMA.TABLES
                       WHERE  TABLE_NAME = 'TableName2') THEN 1
           ELSE 0
           end
  -- and so on
  </code></pre>