title: Load SQL variable in a Select query combined with a condition check
body: <p>Trying to load a declared variable in a SQL select query combined with an EXIST condition check. The condition check works but the variable doesn't get assigned after the condition is tested. Is there a way to do the load and test all in one call?</p>
  <p>This doesn't work, the @FK_FilingId value is not valid after the condition check</p>
  <pre><code>DECLARE @FK_FilingId int;
  SET @FK_FilingId = 0;
  if( EXISTS( SELECT @FK_FilingId = FilingPacketId FROM tbl_Filingtable WHERE Id = @TrackingId))
  BEGIN
      PRINT @FK_FilingId
  END
  </code></pre>
  <p>This does work, but it's not combined in the condition check that I'd like</p>
  <pre><code>DECLARE @FK_FilingId int;
  SET @FK_FilingId = 0;
  SELECT @FK_FilingId = FilingPacketId FROM tbl_Filingtable WHERE Id = @TrackingId
  if( @FK_FilingId &gt; 0 )
  BEGIN
      PRINT @FK_FilingId
  END
  </code></pre>