Removing unwanted rows from sql based on three columns unique ID
<p>Here's the code. I'm doing something dumb - what is it? All I get is "syntax error".</p>

<pre><code>select 
    code, shortDescription, longDescription, fullDescripton, 
    codeType, useThruDate, updateDate, updateComment, createDate
into 
    #irish
from 
    (select distinct 
         code, shortDescription, longDescription
         when count(code + shortDescription + longDescription) &gt; 1
             then delete from #irish where useThruDate &lt;&gt; '2016-30-06'
              else 0
        )
from [dbo].[irish]
</code></pre>

<hr>

<pre><code>code        shortDescription    longDescription                             fullDescription             codeType    useThruDate     updat‌​eDate    updateComment                   createDate 
312291001   47113               Sample text for a description (from 2012)   NULL                        DB1         2016-30-04      2016-06-06    merged all tables together.     NULL 
312291001   47113               Sample text for a description (from 2012)   Lorem ippsum lorem ippsum   DB1         2016-30-06      2016-06-06    merged all tables together.     NULL 
312291001   47113               Sample text for a description (from 2012)   Lorem ippsum lorem ippsum   DB2         2016-31-05      2016-06-06    merged all tables together.     NULL
</code></pre>