I have a console app and I am retrieving data from an API every 2 hours. I would like to insert data if only new into this table but I wonder if there is a way to check data before inserting into table. If I have over 100 records every fetch from this API
and I don't want to manually check one record at a time to see if data in a certain column already exist, how do I write the query to check if data in my records already exist before inserting?
Thanks in advance.
Keep your friends close and your enemies even closer
Member
527 Points
2728 Posts
Before insert check if record exists?
Feb 27, 2021 06:53 AM|cenk1536|LINK
Hi guys,
I have a console app and I am retrieving data from an API every 2 hours. I would like to insert data if only new into this table but I wonder if there is a way to check data before inserting into table. If I have over 100 records every fetch from this API and I don't want to manually check one record at a time to see if data in a certain column already exist, how do I write the query to check if data in my records already exist before inserting?
Thanks in advance.
All-Star
53711 Points
24035 Posts
Re: Before insert check if record exists?
Feb 27, 2021 12:19 PM|mgebhard|LINK
You did not share the code so we can only guess. The following is basic T-SQL.
Member
527 Points
2728 Posts
Re: Before insert check if record exists?
Feb 27, 2021 03:08 PM|cenk1536|LINK
I will get these data below from the API;
id, customerId, firstName, lastName, phone, productCode, orderDate (unix epoch time)
I will use raw SQL in my app, it's much simpler for me.