'Generate DB backup from recent (3 years) data

I'm working with a odl database that stored a large amount of data and I have been asked to send to people we're working with one backup of our database but they need this backup to be smaller than a complete backup of de database.

I mean, they want me to make a backup of recent (3 years to now) data and I'm not sure how to do this.

I work in MS SQL Server 2008 and have been triying to do this:

  1. Create a new empty DB
  2. Generate myDB creation script and use it to give the new DB the original DB table structure, keys, etc...
  3. Use INSERT INTO NEWDB.dbo.TABLE SELECT * FROM MYDB.dbo.TABLE wit all tables, filtering tables I can filter by data, for example, adding "where date > '2016-01-01'
  4. Create a backup of this new database

¿Problem? The original database has hundreds or tables, with hundreds of keys, fields... and for some reason the script I generate fails creating some tables in the new DB and, when use INSERT INTO NEWDB.dbo.TABLE SELECT * FROM MYDB.dbo.TABLE I got some failures I can't easily solve like:

The INSERT statement conflicted with the FOREIGN KEY constraint `"FK_.........". The conflict occurred in database "newtable", table "dbo.table", column 'Codigo'.`

Now... what I'll try is to:

  1. generate a backup of my original db
  2. generate a copy of the db from that backup
  3. filter this copy and generate a new backup of this

Problem? I would have to generate a backup of the entire DB, copy the entire DB and then filter the entire DB (from 1997 to 2018 while I just want to backup data from 2016 to 2018)

So... I would like to ask if exists another way of face this, more easily.

Greetings, Health and Republic.



Solution 1:[1]

I also found that having my version of Excel had written Null into the text file and the Flat File import did not work - I had to remove all of the Nulls and set them to blank.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Casey