views:

396

answers:

6
+3  Q: 

SQL Data Transfer

Hi,

I need to transfer data from one table to the same table in another server which has been truncated. Can somebody please, let me know the easiest way to do it. Please, help me.

Thanks, Chris

A: 

Are you simply bulk-duplicating all records, including PKs? Please post schema - it will affect which technique to use.

le dorfier
+2  A: 

Use the SQL Server Import and Export wizard. It's probably the easiest way to accomplish this task.

For more advanced data transfer, consider using bcp utility, BULK INSERT statement and OPENDATASOURCE.

Mehrdad Afshari
Bear in mind the import/export wizard is seriously borked (at least in SQLServer 2005). We had to stop using it because it didn't maintain foreign key relationships with auto-enerated keys.
cletus
A: 

I would use Data Transformation Services (aka Integration Services).

Andy Webb
Way overkill. He should learn a whole nother software package to load a file?
le dorfier
DTS is totally easy to use - also it comes with SQL server so it's not exactly "another software package"
1800 INFORMATION
+5  A: 

Setup linked servers and then use the following on the destination database:

INSERT INTO existingTable (col1,col2..)

SELECT col1,col2...
FROM linkedserver.dbo.database.othertable
Nick Kavadias
Also remember to consider identity columns, SET IDENTITY_INSERT ON and OFF afterwards. Also check DBCC RESEED as you may not be using IDENTITY(1,1). You were able to truncate, so there must be no foreign keys, but there may be constraints - Check and work with as appropriate.
Meff
+2  A: 

Back up the table on the one server, to a file, and restore that file into the empty table on the other one...

Charles Bretana
this is the best answer. also, more specifically, use the "generate sql" script to export the table data to a comma delimetted file.
djangofan
A: 

Depending on the amount and frequency of your data transfer. It it's a low volume one time process, you're better off with using T-SQL to directly insert the data. This can be done either through linked servers or OPENQUERY clause.

If its high volume one time process, use SSIS or BCP utility.

If its high volume high frequency, use replication.

Nai