Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading selected records from an export...

Status
Not open for further replies.

THoey

IS-IT--Management
Jun 21, 2000
2,142
US
Is this possible? I have a table where I keep data for 45 days. I have a SQL script that deletes from 45 days ago before it does the nightly load. I have set it up so that there is a nightly export done from my database. Due to hastily writing a delete script (<slap>... BAD DBA!), I deleted some records from that table for March instead of February. Is there any way, besides reloading the complete export of the table (too big), to use some sort of WHERE clause to just get those 3 days worth of data?

Any ideas? It isn't really that important, but figured it would be a good learning thing for me try. Looked in the books I have and didn't see anything. Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
No there isn't. If you are pressed for space, export the current table, then truncate it. Import your backup into the empty table and select off what you need into a small table. Truncate the table again and load in today's export, then apply the data from your small table.
 
I figured as much. Like I said, not a big deal. We are going from a production instance that only kept 14 days back to a new and improved instance that will also keep 45 days back. The instance that I deleted it from was this new instance and it is not on line yet. By the time we go to it, that info will probably have dropped off any ways. Just thought I might be able to learn something new today...

Thanks... Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
I don't think that the import utility supports the kind of record selection needed to do this, but there may be a workaround to accomplish the same thing. I would create a second table with the same definition as the table you want to restore. Then define a check constraint on the date column to restrict data to the three days you want to restore. Import to the clone table. You will get a million errors from violations of the check constraint, but hopefully the rows that conform to the three days you want will be successfully loaded. You can then insert the restored data into the original table.
 
Thanks Karluk!!! Again!!! I'll look into that... Terry
**************************
* General Disclaimor - Please read *
**************************
Please make sure your post is in the CORRECT forum, has a descriptive title, gives as much detail to the problem as possible, and has examples of expected results. This will enable me and others to help you faster...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top