Good afternoon,
I have several rows in a table and need to move them to another table.
In the destination table, I also need to add a field with an incremental value.
I do this, but I know that something in the insert is wrong, because the incremental value (intCodInterno) is always the same:
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)
What do I need to change for the value to be fixed?
Thank.
EDIT:
I made a small change to the request, and now it works. I just insert SELECT into IDENT_CURRENT inside brackets:
(SELECT IDENT_CURRENT('Emp_VISOT.dbo.TBL_GCE_ARTIGOS')+1)
I got all the rows that I need from the old table to the new one with an added value.
Thank you all for your help.