title: How to select database tables where they have two or more specific columns in them?
body: <p>How to select database tables where they have two or more specific columns in them?</p>
  
  <p>The one here displays tables with CustomerName in them. To add another column to look for, it seems I might have to add another subquery within the subquery. </p>
  
  <p>I am looking for a simple query where I can add x number of columns without adding complexity.</p>
  
  <pre><code>SELECT t.name AS table_name,
  SCHEMA_NAME(schema_id) AS schema_name,
  c.name AS column_name
  FROM sys.tables AS t
  INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
  WHERE t.name in (select t.name
  FROM sys.tables AS t
  INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID where c.name LIKE '%CustomerID%')
  ORDER BY schema_name, table_name;
  </code></pre>
  
  <p><strong>UPDATE</strong><br>
  Would want to use the LIKE operator</p>