Perform 'Check' of a Datatable (Ids) in batch in the database

Asked

Viewed 52 times

0

I have a small desktop application (Windows Forms - .NET 2.0 - C#) in which I just use it to perform a check on a given time-to-time path and in case this check finds a file. txt in this path, an import of this file is performed.

But this file has a column with a specific ID and what I do today, is row by row check if this ID exists in the database. If yes, ignore it, if you don’t mind.

What I would like to have a help with is there any way I can do this in batch? Without a "loop" line-to-line. Something that I sent to the bank this list of Ids and he performed an "IN" and returned me which were not found, and then yes perform the insertion (Bulk Insert).

  • You can add the verification code snippet of the id you currently use ?

  • You can use a stored Procedure with a table parameter, thus sending a datatable with the ids and making the logic within the stored Precedent. Add the relevant code snippets to the question that we can help you best.

  • @stringName to which end? ^~

  • @Marciano.Andrade I did exactly that when I published the post here and it was sensational! Thanks!

1 answer

0

The solution found was to create a TYPE with a TABLE structure and, later, a STORED PROCEDURE that checks in the IN if the data sent by . NET exist in the database. The return was sensational. I managed to reduce the time from ~40min. to ~3min. a total of 13 files and more than 100,000 records.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.