title: Set variable to NULL if not found in query statement
body: <p>I have following code </p>
  
  <pre><code>DECLARE @a INT
  
  SET @a = 1
  
  SELECT TOP 1
      @a = id
  FROM
      test
  WHERE
      name = 'notexist'
  
  SELECT @a
  </code></pre>
  
  <p>variable <code>@a</code> will still have <code>1</code> value if the <code>SELECT</code> statement doesn't find any row, is it possible to set the <code>@a</code> variable to null if the <code>SELECT</code> statement doesn't find any row without adding <code>SET @a = NULL</code> before <code>SELECT</code> statement?</p>