471,050 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,050 software developers and data experts.

Backup restoration / append query

Hi All:

Being a bit of a nube to MSSQL I could use a little advice. This is the
situation.

A client's HDD became full so I backed up, deleted then recreated a blank
database (they said they didn't need the stored data).
They have now deceided that they want the data again.

My plan is to restore the database to a second volume so it can grow as much
as is needed, however, there is now data in the second instance that would
need importing to the restored DB.

I can restore the backed up db with a different name and reconfigure the
software that accesses it but what would be the best method to append the
restored DB with the data in the current instance of said DB? Both DBs are
identical.

TIA

MP

Jul 20 '05 #1
1 3082

"Max Power" <Ma*******@excelence.co.uk> wrote in message
news:bu**********@sparta.btinternet.com...
Hi All:

Being a bit of a nube to MSSQL I could use a little advice. This is the
situation.

A client's HDD became full so I backed up, deleted then recreated a blank
database (they said they didn't need the stored data).
They have now deceided that they want the data again.

My plan is to restore the database to a second volume so it can grow as much as is needed, however, there is now data in the second instance that would
need importing to the restored DB.

I can restore the backed up db with a different name and reconfigure the
software that accesses it but what would be the best method to append the
restored DB with the data in the current instance of said DB? Both DBs are
identical.

TIA

MP


There's no generic way to 'merge' two databases, but as a very general
approach, you can do something like this for each table:

insert into DestinationDB.dbo.Table1 (col1, col2, ...)
select col1, col2, ...
from SourceDB.dbo.Table1 s
where not exists (select * from DestinationDB.dbo.Table1 d
where d.PrimaryKeyColumn = s.PrimaryKeyColumn)

But there are potential issues - foreign keys mean you have to populate the
tables in the correct order (or disable them during load), and if tables are
using IDENTITY columns or other artificial keys, then you might exclude
valid data. You also might be able to exclude tables which hold static data
such as countries and currencies.

Simon
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by xabaras | last post: by
2 posts views Thread by emmexx | last post: by
2 posts views Thread by Tommy.Vincent | last post: by
1 post views Thread by Lan W via DBMonster.com | last post: by
2 posts views Thread by rdemyan via AccessMonster.com | last post: by
reply views Thread by Now You Know | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.