title: TSQL - Assign value from query to variable if record exists in a single select
body: <p>How I can improve below code to use 'select' only once?</p>
  
  <pre><code>IF EXISTS (SELECT [NUMBER] FROM [TABLE] WHERE [ID_RECORD] = @id_record
  BEGIN
     DECLARE @tmp_variable
     SELECT @tmp_variable = [NUMBER] FROM [TABLE] WHERE [ID_RECORD] = @id_record
  
     SET @other_variable = @tmp_variable
  END
  ELSE
  BEGIN
     SET @other_variable = 0
  END
  </code></pre>