title: Identity with variable seed
body: <p>I have this code, i'm trying to set the identity seed by a varable</p>
  
  <pre><code>DECLARE @iKeyX INT
  
  SELECT @iKeyX = MAX(KeyX) FROM Temporales..tmp_Orders
  
  IF (@iKeyX = NULL)
     SET @iKeyX = 1
  ELSE
     SET @iKeyX = @iKeyX + 1
  
  IF OBJECT_ID('tempdb..#tmp_Orders','U') IS NOT NULL
     DROP TABLE #tmp_Orders
  
  SELECT  IDENTITY(INT, @iKeyX, 1) AS KeyX,
          0 AS Valido, 
          OrderNumber, 
          OrderType, 
          Code, 
          Size, 
  INTO #tmp_Orders
  FROM TableWithData
  </code></pre>
  
  <p>Why SQL keeps telling me "Incorrect syntax near '@ iKeyX'"?</p>