Last post Feb 27, 2021 03:08 PM by cenk1536
Feb 27, 2021 06:53 AM|cenk1536|LINK
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.
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.
IF( NOT EXISTS(SELECT (1) FROM [Production].[Product] WHERE [ProductNumber] = 'AR-5382'))
print 'Does not exist'
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.