SQLTeam.com | Weblogs | Forums

Check duplicate records during insert


#1

Dears

I have entries in the table in below format initially.
then daily delta records are getting inserted in this table, i need to check the below condition and increase the (SCHED_LiNE) counter before inserting the record only if this combination(Invoice_no and S_ORD_Item) is same.

i am generating a counter in column (SCHED_Line), based on 2 columns Invoice_no and S_ORD_Item is same
and this counter(SCHED_Line) will change whenever the combination (Invoice_no and S_ORD_Item) is changing.

Example:-
Initial data available in table
A893131032017 1 1
A893131032017 1 2
A893131032017 1 3
A895762032017 1 1
A895762032017 1 2
A895762032017 1 3

Expected results for daily delta records that will insert
A893131032017 1 1
A893131032017 1 2
A893131032017 1 3
A893131032017 1 4
A895762032017 1 1
A895762032017 1 2
A895762032017 1 3
A895762032017 1 4