title: SQL server insert multiple rows and incrementing a int column
body: <p>I have some rows in a table and need to transfer them to another table. In the destination table i need also to add a field with an incremental value.</p>
  
  <p>I'm doing the following, but i know that something in the insert is wrong, because the incremented value (intCodInterno) is always the same:</p>
  
  <blockquote>
  <pre><code>INSERT INTO Emp_VISOT.dbo.TBL_GCE_ARTIGOS
          ( strCodigo ,
            strDescricao ,
            intCodInterno ,
            intCodTaxaIvaCompra ,
            intCodTaxaIvaVenda ,
            strCodCategoria ,
            strAbrevMedStk ,
            strAbrevMedVnd ,
            strAbrevMedCmp ,
            bitAfectaIntrastat
          )(
          SELECT  A.Artigo ,
                  a.Descricao ,
                  IDENT_CURRENT('Emp_VISOT.dbo.TBL_GCE_ARTIGOS')+1,
                  '3' ,
                  '3' ,
                  '1' ,
                  'Un' ,
                  'Un' ,
                  'Un' ,
                  '0'
          FROM PRIVESAM.DBO.Artigo A)
  </code></pre>
  </blockquote>
  
  <p>What do i need to change so the value is incremented correcty?</p>
  
  <p>Thank you.</p>
  
  <p><strong><em>EDIT:</em></strong></p>
  
  <p>I made a small change in the query, and now it works.
  I just insert a SELECT in the IDENT_CURRENT inside brackets:</p>
  
  <pre><code>(SELECT IDENT_CURRENT('Emp_VISOT.dbo.TBL_GCE_ARTIGOS')+1)
  </code></pre>
  
  <p>I got all the rows that i need from the old table to the new with the incremented value. </p>