title: SQL Server Error: Cannot continue the execution because the session is in the kill state
body: <p>When I ran the below query in SQL Server 2016 Getting the below-mentioned error.</p>
  
  <p>Query:</p>
  
  <pre><code>DECLARE @INCR_DATE DATETIME
  
  SET @INCR_DATE = (SELECT DATEADD(DD, -1, MIN(DT)) 
                    FROM
                        (SELECT MAX(Record_Updated_Datetime) AS DT 
                         FROM [LINKEDSERVER].Test.dbo.Customer WITH(NOLOCK)
                         UNION ALL
                         SELECT MAX(Record_Updated_Datetime) AS DT 
                         FROM STAGE.dbo.Customer WITH(NOLOCK) 
                         WHERE [Source] = 'TEST') INCR)
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>Msg 596, Level 21, State 1, Line 38<br>
    Cannot continue the execution because the session is in the kill state.</p>
    
    <p>Msg 0, Level 20, State 0, Line 38<br>
    A severe error occurred on the current command. The results, if any, should be discarded.</p>
  </blockquote>
  
  <p>When I ran the Select statement individually it is working fine. But when I ran with <code>UNION ALL</code>, it is throwing this error.</p>
  
  <p>Also, it is giving error only in one machine (eg.QA) in DEV and PROD box query is running fine.</p>
  
  <p>What could be the issue?</p>
  
  <p>NOTE: DEV, QA, PROD - Same server settings</p>