Link to home
Start Free TrialLog in
Avatar of allenkent
allenkentFlag for United States of America

asked on

Using Stored Proceedure to Copy Table Data from Server A to Server B

USE [MyDatabaseABC]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[uspUpdateTableData]
AS
DELETE FROM MyDatabaseABC.CustomerInformation;
INSERT INTO MyDatabaseABC.dbo.CustomerInformation
SELECT * FROM MyOtherDatabase.dbo.CustomerInformation;

The issue is the SELECT * FROM is a different server. How do I code this to look at a different server? Can  I do this? My goal is to remove all data and repopulate it with data from a different server. The new data is SQL 2008 the old data is on SQL 2005
SOLUTION
Avatar of John_Vidmar
John_Vidmar
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Be sure the data volume is low enough that you really want to do a delete and re-insert.  You could use Change Tracking, as one example, to just determine modifications (DELETE, INSERT, UPDATE) and apply those instead.  Or delayed replication, etc..
Avatar of allenkent

ASKER

I keep getting error:

Msg 102, Level 15, State 1, Procedure uspUpdateTableData, Line 5
Incorrect syntax near '-'.
My server name is:   DD-01   (it has a dash). Is that the issue?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial