title: check if duplicate exists in a column and do something sql
body: <p>I have a email address column in my database, I want to check if there are duplicates do TASK FAILURE PATH and if there is only one entry do TASK SUCCESS PATH </p>
  
  <pre><code>    DECLARE @DuplicateCount int=
              (
                  SELECT COUNT(*)
                  FROM tblWebPortal_Login
                  WHERE Email = 'abe@abeprakash.com' 
                  GROUP BY email
                  HAVING COUNT(email) &gt; 1
              );
              select @DuplicateCount 
  
  if @DuplicateCount is null
  TASK SUCCESS PATH
  else
  TASK FAILURE PATH
  </code></pre>
  
  <p>The issue i have is @DuplicateCount is returning null if there is only one entry and if there is no email address present. i.e., TASK A is done for email address which is only present once (which is correct) however TASK A is done if email is some garbage data (Which is wrong)</p>
  
  <p>I am using SQL Server 2016</p>