title: TSQL: if statement inside a select insert
body: <p>I have this structure inside a function: </p>
  
  <pre><code>INSERT INTO @TheTable
      SELECT DISTINCT
  
          @Number AS Number,
  
          @Name AS Name
  
      FROM MYTABLE 
      WHERE id = @id
  </code></pre>
  
  <p>I need to add to this structure the result of executing another function and I need your help to do so. </p>
  
  <p>Below the @Name AS Name, line I should add something like this</p>
  
  <pre><code>IF (dbo.anotherFunction(@id)==1) 
  @NewVisitor AS NewVisitor
  ELSE
  @NewVisitor AS NoNewVisitor
  </code></pre>
  
  <p>How can I translate this into TSQL?? </p>
  
  <p>Thanks a million!</p>