title: Programmatically set identity seed in a table variable
body: <p>I need to create a table variable with an identity seed that starts with the max value of a field in another table?</p>
  
  <p>I've tried this:</p>
  
  <pre><code>DECLARE @IdentitySeed int
  
  SET @IdentitySeed = (SELECT MAX(HHRecId) +1 FROM xxx )
  
  DECLARE @HH TABLE (
      HHId INT IDENTITY(@IdentitySeed,1)
      ,AddressType CHAR(1)
      ,Address1 VARCHAR(100)
      ,City VARCHAR(50)
      ,State VARCHAR(2)
      ,Zip VARCHAR(5)
      ,LastName VARCHAR(50)
      )
  </code></pre>
  
  <p>But that gives a syntax error.</p>
  
  <p>For now, I've added another int column to the table variable and update that with the sum of the identity column and @IdentitySeed but I would like to find a way to do that without the update.</p>