title: How to find which columns don't have any data (all values are NULL)?
body: <p>I have several tables in a database. I would like to find which columns (in which tables) don't have any values (all NULL in a column). I the example below, the result should be </p>
  
  <pre><code>TestTable1 --&gt; Var2
  TestTable2 --&gt; Variable1
  </code></pre>
  
  <p>I don't have any idea how to create this kind of query. Your help is most appreciated!</p>
  
  <pre><code>--create first table
  create table dbo.TestTable1 (
  sur_id int identity(1,1) not null primary key,
  var1 int null,
  var2 int null
  )
  go
  
  --insert some values
  insert into dbo.TestTable1 (var1) 
      select 1 union all select 2 union all select 3
  
  --create second table
  create table dbo.TestTable2 (
  sur_id int identity(1,1) not null primary key,
  variable1 int null,
  variable2 int null
  )
  
  --and insert some values
  insert into dbo.TestTable2 (variable2) 
      select 1 union all select 2 union all select 3
  </code></pre>