I'm given the task to export the content of a huge table from a production database and to import the data into a database at a remote location.
The Table has about 45,000,000 rows. using about 4 GB space in the database.
Its 10 Columns are of type int, datetime and varchar(n) <= 255, but some of the varchar fields contain newlines and the usual field separators used by bulkcopy.
I guess export to Excel is no option due to the number of rows. Export with SSIS to Flatfile is possible (took about 30 minutes), but reimport is not automatic, since some fields where spitted.
My current idea is
- create a new database on the production server (using same collations as the production database)
- Set its recovery mode to simple
- copy the data with Select * into copy_of_table from prod_db..big_table
- Detach mdf file from this new database and ship it to the other location
- Drop adhoc database
I assume that inserting into a database with simple recovery model generates only minimal logging on the new database and this way is one of the fastest possible to export the data and the impact to the production database is the least possible.