Cannot insert duplicate key row in object 'tarInvoiceLog' with unique index 'XAK1tarInvoiceLog'.
The statement has been terminated.
I get this error when I run insert statement within cursor ( I need to do line by line processing).
I checked for duplicates, there are none. If I run single insert, no errors.
-- create inv tran id
set @inv_tran_id = @inv_tran_no + '-IN'
-- generate inv key
exec dbo.spGetNextSurrogateKey 'tarInvoiceLog', @inv_key output
print 'inv tran id ' + @inv_tran_id
print 'inv_tran No ' + @inv_tran_no
print 'inv_key ' + cast(@inv_key as varchar(10))
-- insert into invoice log table
if @inv_key > 0
begin
insert into tarInvoiceLog
select
@inv_key, 'IBR'
, 0, @inv_date
, @inv_tran_id
, @inv_tran_no
, 3, @batch_type
Any ideas that might help me solve this problem?
Thanks
Steve
The statement has been terminated.
I get this error when I run insert statement within cursor ( I need to do line by line processing).
I checked for duplicates, there are none. If I run single insert, no errors.
-- create inv tran id
set @inv_tran_id = @inv_tran_no + '-IN'
-- generate inv key
exec dbo.spGetNextSurrogateKey 'tarInvoiceLog', @inv_key output
print 'inv tran id ' + @inv_tran_id
print 'inv_tran No ' + @inv_tran_no
print 'inv_key ' + cast(@inv_key as varchar(10))
-- insert into invoice log table
if @inv_key > 0
begin
insert into tarInvoiceLog
select
@inv_key, 'IBR'
, 0, @inv_date
, @inv_tran_id
, @inv_tran_no
, 3, @batch_type
Any ideas that might help me solve this problem?
Thanks
Steve