I have a SQL table that i'm trying to insert new data every day, but im concerned that a duplicate row may be inserted. Is there a way to validate if a data is existing before inserting new records. I'm thinking to use a date field or can you validate the entire row? thanks.
Solved! Go to Solution.
Hi @iamRandy
Do these tables have a primary key?
1)I think that the best option would be to use the option Update; Insert if new.
Another 2 options if the previous one is not possible, these usually works but i think it is not like a good practice 😅.
2)You can compare input and compare both tables (first one would be pick the max date from some column of the previous day table, compare with the current day table and filter just dates after that.)
3)second one, join both tables by the proper columns and let just the new data go to the output
My table is historical YTD .. let me try your suggestion
No there's no primary key.
If you have historical data with some date column that can be used to separate old data from new date, the second option will work
I created a primary key field (RecordID) and i am able to insert new rows
User | Count |
---|---|
52 | |
27 | |
25 | |
24 | |
21 |