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

more ▼

asked May 25, 2010 at 04:42 PM in Default

avatar image

81 10 10 15

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

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?

more ▼

answered May 25, 2010 at 05:01 PM

avatar image

15.6k 22 57 38

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: May 25, 2010 at 04:42 PM

Seen: 1097 times

Last Updated: May 27, 2010 at 02:56 AM

Copyright 2018 Redgate Software. Privacy Policy