title: How to find out whether a table has some unique columns
body: <p>I use MS SQL Server.</p>
  
  <p>Ive been handed some large tables with no constrains on them, no keys no nothing.</p>
  
  <p>I know some of the columns have unique values. Is there a smart way for a given table to finde the cols that have unique values ?</p>
  
  <p>Right now I do it manually for each column by counting if there is as many DISTINCT values as there are rows in the table.</p>
  
  <pre><code>SELECT COUNT(DISTINCT col) FROM table
  </code></pre>
  
  <p>Could prob make a cusor to loop over all the columns but want to hear if someone knows a smarter or build-in function.</p>
  
  <p>Thanks.</p>