Sql-server – Need help merging multiple full SQL Server Backups into single database

backuprestoresql server

Got a really strange issue with SQL Server database backup files I am getting backup files from the state of California for petroleum production. Each year a database with the same name is created for the data for that year The database is always named, WellProductionInjection. Each year the same tables with the same contents are created and populated. The only difference is that the table names contain the year, so separate tables as supposed to exist for each year. I can get what is labelled as a full backup file for a single year. But when I try to use SQL Server Management Studio to restore all the backup files to a single database, I get only the data for one year, or an error about the database already existing. Any tips on how deal deal with merging multiple backups into a single database? Examples of the backup files can be put on the web if anyone is willing to try their luck with this.

Best Answer

SQL server doesn't have any built-in capacity to merge multiple backups into a single database, you'll have to restore each backup with a different database name (like WellProductionInjection_2019 and WellProductionInjection_2020), then do the work yourself to combine them however you need.

Once the databases are restored, you can combine them using a variety of tools; the simplest one is called the "Import/Export Wizard". You can use this to copy entire tables from one database to another (if all tables have different names), or to append the data from table in one database to the tables in the other (if you actually want to combine the data into the same table).