question

Stan avatar image
Stan asked

Accidentally import flat file into wrong table

When I use import wizard to import CSV file, I accidentally select wrong destination table and finish the import. I am not

sql-server-2000import-data
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
TimothyAWiseman avatar image
TimothyAWiseman answered

I am not sure exactly what you ar asking, but if you are asking about how to undo this, there are a couple of options to explore depending on the details of your situation.

The obvious answer if you are in full recovery mode is to do a point in time restore to before the accidental import. Depending on if any other transactions might have been occuring in that time frame in that database, you may be able to simply restore over your current database and be done with it. If transactions have been occuring in that database, but not on that table, then you can restore to a different location, and then just move the restored table over.

Alternately, you may want to look at some of the auditing software available. This requires that you are already in full backup mode, but if so some of the programs have sophisticated abilities to sort through the transaction logs and undo specific transactions. I am not prepared to recommend any of them since I do not use such programs on a regular basis, but there are a couple of options out there. The caveat is that they can be extremely slow and somewhat tedious to use, especially on a highly active database.

If you cannot do that, you can write a script to import that CVS file (could you actually mean CSV?) into a different table and then delete precisely those records from your table. This of course assumes that there is no chance that any of the lines from your file might have already been in your table, but if you have a unique index on any of your data rows then that is a safe assumption since otherwise it would have rolled back and this problem would not exist. The nice thing about this option is that it does not require you to either be in fullbackup mode or have a recent backup available.

Hopefully this will help you solve your problem, but if not could you clarify it slightly?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.