title: T-SQL, Insert into with MAX()+1 in subquery doesn't increment, alternatives?
body: <p>I have a query where I need to "batch" insert rows into a table with a primary key without identity.</p>
  
  <pre><code>--TableA
  --PK int (Primary key, no-identity)
  --CustNo int
  INSERT INTO TableA (PK,CustNo)
    SELECT (SELECT MAX(PK)+1 AS PK FROM TableA), CustNo
    FROM Customers
  </code></pre>
  
  <p><em>(simplified example - please don't comment about possible concurrency issues :-))</em></p>
  
  <p>The problem is that it doesn't increment the PK "for each" processed row, and I get a primary key violation. </p>
  
  <p>I know how to do it with a cursor/while loop, but I would like to avoid that, and solve it in a set-based kind of manner, if that's even possible ?</p>
  
  <p>(running SQL Server 2008 Standard)</p>