title: SQL Server 2008 Select certain columns have specific data
body: <p>I have a table some of its columns are of a <code>bit</code> datatype. I need to select only the <code>[BIT]</code> datatype columns and with the value of <code>[TRUE]</code>.</p>
  
  <p>I have the following code to select only the <code>[BIT]</code> columns from a given table.</p>
  
  <pre><code>SELECT 
      OBJECT_NAME(c.OBJECT_ID) TableName, c.name ColumnName
  FROM 
      sys.columns AS c
  JOIN 
      sys.types AS t ON c.user_type_id= t.user_type_id
  JOIN
      sys.all_objects as o ON o.object_id = c.object_id
  WHERE 
      t.name = 'bit' 
      AND o.name = 'TABLENAME' --this is the table name
  ORDER BY 
      c.OBJECT_ID
  GO
  </code></pre>
  
  <p>Please tell me how to select only those with [TRUE] value</p>
  
  <p>thanks</p>