title: SQL Select Case Conversion failed when converting the varchar value to data type int.
body: <p>Folks, I've read the fixes for this issue but I have a variation that I can't solve.</p>
  
  <p>Firstly the following syntax throws the error</p>
  
  <pre><code> Case
      when #TFs.lTFID = 1161165 then REPLACE(CONVERT(VARCHAR(11), cast([dCreatedUTC] as datetime), 106), ' ', '-')
      when #TFs.lTFID = 1161166 then 'Administrator'
      when #TFs.lTFID = 1161167 then ''
      when #TFs.lTFID = 1161168 then AssetID
      when #TFs.lTFID = 1161169 then ''
      when #TFs.lTFID = 1161170 then ''
      when #TFs.lTFID = 1161172 then ''
      when #TFs.lTFID = 1161173 then ''
      else CAST(#TFs.lTFID as varchar(20))
    End 'Value'
  </code></pre>
  
  <p>If I comment out all but one of the "when" lines as below it works.</p>
  
  <pre><code> Case
      when #TFs.lTFID = 1161165 then REPLACE(CONVERT(VARCHAR(11), cast([dCreatedUTC] as datetime), 106), ' ', '-')
  /*  when #TFs.lTFID = 1161166 then 'Administrator'
      when #TFs.lTFID = 1161167 then ''
      when #TFs.lTFID = 1161168 then AssetID
      when #TFs.lTFID = 1161169 then ''
      when #TFs.lTFID = 1161170 then ''
      when #TFs.lTFID = 1161172 then ''
      when #TFs.lTFID = 1161173 then ''*/
      else CAST(#TFs.lTFID as varchar(20))
    End 'Value'
  </code></pre>
  
  <p>Any thoughts about how I can format this query so that all "cases" work?</p>