title: Dynamix SQL Error "Must declare the scalar variable"
body: <p>I have the @inAdd1-6 and @inAdd declared.  The @inAdd1-6 will actually be passed into the Stored Procedure.</p>
  <p>I will then split them and process the addresses, some as a single address, and others where I compare names, street, zip codes, etc.</p>
  <p>I was HOPING I could dynamically change change the @inAdd to each one as I needed to process it  ie <code>SET @inAdd = @inAdd#</code></p>
  <pre><code>DECLARE
      @id nvarchar(255)        = '[uid]',
      @table      varchar(255) = '[sub_customer]',
      @company    varchar(255) = '',
      @inAdd nvarchar(max)     = '',
      @inAdd1 nvarchar(max)    = 'BLANK,[Invoice Street],BLANK,BLANK,BLANK,[Invoice City],[Invoice State],[Invoice Zip],[Invoice Country]',
      @inAdd2 nvarchar(max)    = '[Shipping Name],[Shipping Street],BLANK,BLANK,BLANK,,[Shipping City],[Shipping State],[Shipping Zip],[Shipping Country]',
     @inAdd3  nvarchar(max)    = '[UPS Company],[UPS Street],BLANK,BLANK,BLANK,,[UPS City],[UPS State],[UPS Zip],[UPS Country]',
     @inAdd4  nvarchar(max)    = '[FedEx Name],[FedEx Street],BLANK,BLANK,BLANK,,[FedEx City],[FedEx State],[FedEx Zip],[FedEx Country]',
     @inAdd5  nvarchar(max)    = 'BLANK,[UPS From Street],BLANK,BLANK,BLANK,,[UPS From City],[UPS From State],[UPS From Zip],[UPS From Country]',
     @inAdd6  nvarchar(max)    = 'BLANK,[FedEx From Street],BLANK,BLANK,BLANK,,[FedEx From City],[FedEx From State],[FedEx From Zip],[FedEx From Country]',
  
  WHILE (@addCnt &gt;= @cnt)
  BEGIN
      SET @var = '@inAdd' + CAST(@cnt AS nvarchar(3))
      PRINT @var
      SET @sql = 'SET @inadd = ' + @var
      PRINT @sql
      EXEC sp_executesql @sql
      SET @cnt = @cnt + 1
      ... code to process @inAdd
  END
  </code></pre>
  <p>The @sql in the PRINT is <code>SET @inadd = @inAdd1</code> which is exactly what I want.  However, when I use sp_executesql I get the error.</p>
  <p>If put in <code>SET @inadd = @inAdd1</code> (or any other @inAdd#) as a separate command it works fine.</p>