Hi Lido98 and welcome to DaniWeb :)
This can be done in SQL Management Studio in a few easy steps:
First of all, you need to connect to Server B.
Once connected, you need to link Server A to Server B. In SQL Mngmt Studio 2005, this can be done by right-clicking Linked Servers under the Server Objects field and adding the new linked server.
Then you need to run a query similar to the one below.
INSERT INTO ServerB.DatabaseName.dbo.Employee
(SELECT * FROM ServerA.DatabaseName.dbo.Employee)
Where ServerA is the server name of Server A, similar for ServerB and DatabaseName is the name of the databases on each server. I should also point out that if the Employee table has an auto increment field and you want to preserve the order of this field, you need to set auto increment off for the ServerB Employee table before you run the insert and reset it to on when you have finished. Let us know if you need to do this and we'll show you how.
Anyway, hope this helps :)
d
darkagn
Veteran Poster
1,197 posts since Aug 2007
Reputation Points: 404
Solved Threads: 200
Hi again,
The easiest way to avoid duplicates is to limit the select statement according to some criteria. Do you have an ID field in the table that you can use, or some sort of date field to specify when the object was inserted? ID is easiest:
INSERT INTO ServerB.DatabaseName.dbo.Employee B
(SELECT * FROM ServerA.DatabaseName.dbo.Employee A
WHERE B.ID NOT IN (SELECT ID FROM A)
but date can also be done:
INSERT INTO ServerB.DatabaseName.dbo.Employee B
(SELECT * FROM ServerA.DatabaseName.dbo.Employee A
WHERE B.DATE > (SELECT MAX(DATE) FROM A)
Let me know if you don't have such a structure in this table (maybe describe the primary key for me please?)
To backup the database first (which is ALWAYS a good idea btw), in SQL mngmnt studio 2005, right-click the database and select Tasks from the popup menu and select Back Up from the submenu. You need to check the settings in the screen that appears, pretty much the only thing I ever change is the destination. Press the Backup button and watch the magic unfold!
HTH,
d
darkagn
Veteran Poster
1,197 posts since Aug 2007
Reputation Points: 404
Solved Threads: 200
What is the type for the field 'creationdate'? Is it a date, datetime, smalldatetime or something else?
darkagn
Veteran Poster
1,197 posts since Aug 2007
Reputation Points: 404
Solved Threads: 200