title: How to change the structure of a table if a variable is null
body: <p>I'm selecting a table from a stored procedure which returns different columns if one of my variables is null vs. when it isn't.  How do I declare a table differently based on one of my inputs?  The code below communicates what I'm trying to do, but I get an error that I'm declaring the table twice if I try to do it this way.</p>
  
  <pre><code>IF @Input IS NOT NULL BEGIN
  DECLARE @tbl AS TABLE (
      Var1 FLOAT,
      Var2 DATETIME,
      VAR3 INt,
      ...
  )
  END
  ELSE
  DECLARE @tbl AS TABLE(
      Var1 INT,
      Var2 FLOAT,
      Var3 DATETIME,
      ...
  )
  </code></pre>