Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 How to restore and append to an existing database

Author  Topic 

mediashri
Starting Member

1 Post

Posted - 2010-05-10 : 08:16:41
Hi,
I have a sql server 2008 database on our server. i now have 6 databases on 6 laptops with the same architecture and schema, stored procs etc. I now need to append the data of these 6 laptop databases to the main database which is situated on the server. How can i restore the laptop databases on the main database so that the laptop data is appended to the main database.
How does one use synchronization or replication to achieve this.
Also how does the restore command append rows to the database.
I need help real fast and would really appreciate it.
Thanks.

Kristen
Test

22859 Posts

Posted - 2010-05-10 : 09:18:49
You cannot restore "append" to a database.

You could restore to a separate, temporay, database and then for each table do:

INSERT INTO MyMainDatabase.dbo.MyTable
SELECT * FROM MyTempDatabase.dbo.MyTable

repeat for appropriate tables, and then repeat the restore for each "source" database you want to append.

Do you have any Identity columns in the tables? they will be a problem. You probably want to allocate new IDs for them - but will that break the data (i.e. are those IDs used for cross-reference in other tables in the source data?)

Are there Primary Key fields that are NOT unique between each copy of the database? If so, like the Identity numbers, you will have to sort those out too before you can "append-merge" the data.

Yes, you could use replication for this on an ongoing basis, but it certainly wouldn't be worth going to the trouble of setting it up for a one-off merge-append.
Go to Top of Page
   

- Advertisement -