I have a stored procedure that executes a BULK INSERT of a flat file into a temp table. Upon some validation checks, I then INSERT this data into a database table; truncating the original data first. This is all done in a transaction that can be rolled back in case of an error.
I have come across the situation where I will not need to truncate the original data first. I need to append the data to certain tables. I need to be able to check if I am getting rows in my flat file that would result in duplicates in the data I already have in my database.
I figured that once I have the flat file data in my temp table, I could query this temp table and the actual table to find if dups exist.
Is this a smart or efficient way to do this and if so, how would I write that query?
Sql Server 2005
Thanks
I have come across the situation where I will not need to truncate the original data first. I need to append the data to certain tables. I need to be able to check if I am getting rows in my flat file that would result in duplicates in the data I already have in my database.
I figured that once I have the flat file data in my temp table, I could query this temp table and the actual table to find if dups exist.
Is this a smart or efficient way to do this and if so, how would I write that query?
Sql Server 2005
Thanks