Say I have hundreds of thousands of records in a text file which I'd like to insert into the database every day. Of which around half of them already exist within the database. Also an unique row is defined using say 6 columns.
What is the correct way to code the insert in .NET in this particular case? The two which I'm wondering over are:
Do I SQL-insert straight away and catch the SQLException for duplicate entries? In this case, I'd be breaking the concept that Exceptions should be used only for exceptional cases and not for the frequent cases.
or
Do I do a SQL-select first to check for the row before I do an insert? In this case, it'd seem that the database will do the insert and check for the uniqueness a second time automatically despite having just completed a select.