# Prevent duplicate data entry in SQL through KNIME

**URL:** <https://forum.knime.com/t/prevent-duplicate-data-entry-in-sql-through-knime/47392>\
**Category:** KNIME Analytics Platform\
**Created:** [September 20, 2022, 5:49pm UTC](https://forum.knime.com/t/prevent-duplicate-data-entry-in-sql-through-knime/47392 "2022-09-20T17:49:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex1368](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/a/f0a364/32.png) [@alex1368](https://forum.knime.com/u/alex1368)\
**Post date:** [September 20, 2022, 5:49pm UTC](https://forum.knime.com/t/prevent-duplicate-data-entry-in-sql-through-knime/47392/1 "2022-09-20T17:49:43Z")

</div>

I have a lot of data and information that is added daily, which is too much and cannot be stored in Excel.  
I want to enter that information into the SQL database and use it later  
I want to prevent duplicate data entry (based on two columns) during data entry.  
How can I do this through KNIME?  
I use the following nodes to enter information

 ![آپلود در sql](https://forum-cdn.knime.com/uploads/default/original/3X/2/d/2dfd5348a8934acd1035573fe1b78769dd2517fd.jpeg)

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [September 20, 2022, 6:06pm UTC](https://forum.knime.com/t/prevent-duplicate-data-entry-in-sql-through-knime/47392/2 "2022-09-20T18:06:25Z")

</div>

@alex1368 typically a database would prevent duplicate entries thru PRIMARY keys. You might want to check your database and configure it that way. You could also do that with a local H2 database for example. Then you might have to decide what to do if you encounter a duplicate key

You can also check in advance if your database already has the keys you want to insert beforehand and then act accordingly.

These examples might be worth exploring. But maybe you give us some more details about what you ant to do and maybe even some dummy/sample data to illustrate your point.

> [@How to update database with scraped data](https://forum.knime.com/t/how-to-update-database-with-scraped-data/38485/3):
>
> @RIchardC I put together a (hopefully) complete example using [H2](https://hub.knime.com/search?tag=h2&type=Workflow) and the [Northwind](https://kni.me/w/FFMXKZxocyhP2A2I) database with customerid. Here we first create a database with a customerid as a primary key (randomly selected from the central DB). Then every 10 seconds another random batch gets drawn. Existing customerid will be updated. Then the workflow determines which customerid are new and would insert them. If a row is inserted initially a timestamp first\_inserted will be stored. Then with every update another timestam…

[https://hub.knime.com/search?type=Workflow&tag=update,sql&sort=maxKudos](https://hub.knime.com/search?type=Workflow&tag=update,sql&sort=maxKudos)

> [@How can I accomplish on KNIME "INSERT ... ON DUPLICATE KEY UPDATE Statement"?](https://forum.knime.com/t/how-can-i-accomplish-on-knime-insert-on-duplicate-key-update-statement/32016/10):
>
> @bilgee I would like to point you to a KNIME-only solution to your task since that might be what you initially asked Also I created an example using H2 database and Stud\_id as PRIMARY\_KEY and load everything into a new database

> **[Example of H2 database - handling of database structure and use of Primary...](https://hub.knime.com/mlauber71/spaces/Public/kn_example_db_h2_primary_key~6FTnVIO23WDsDWxt/current-state)**
>
> Example of H2 database - handling of database structure and use of Primary Keys - insert only new lines by ID

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [December 19, 2022, 6:07pm UTC](https://forum.knime.com/t/prevent-duplicate-data-entry-in-sql-through-knime/47392/3 "2022-12-19T18:07:04Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
