title: finding duplicate records in sql server table
body: <p>I know this is a very common questions and it has been answere and asked on stackoverlow tons of times, I have a same situtation but with a small catch </p>
  
  <p>I am trying to use group by clause to get the duplicates and if they exists make an update and if they don't just do an insert </p>
  
  <pre><code>SELECT      name,age,sex, COUNT(1) as CNT
  FROM        CUSTOMER
  GROUP BY    name,age,sex;
  </code></pre>
  
  <p>there is also a field called as <code>datecreated</code> which holds currenttimestamp and it is different for every record and even for duplicates </p>
  
  <p>how can i create a query which will will hold off this and that if all the above has a <code>cnt</code> greater than <code>1</code> , just do an <code>update</code> and else do an <code>insert</code> </p>