Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Data From One Table Another Table

Status
Not open for further replies.

Creeder

Programmer
Jul 5, 2000
110
MY
Hi all,

How would i copy data from table A to another table B(with some new columns) where both table is located at different servers?

Eg. Server A
Table A : Columns: Cust_id,name,lastname

Server B
Table B: Columns: Cust_id,name,lastname,birthday

Any help is greatly appreciated.
 
I'm relatively new to SQL server databases but will be tackling a similar situation in the near future. The way I intend to tackle it is as follows. If you're wanting to copy data from a remote server to a local server you should first link the remote server using the 'sp_addlinkedserver' command such that the local server recognises the linked remote server. Following this you can run a query something like 'INSERT INTO [local-server-name].[database1].dbo.[Table1] ([Field1], [Field2], [Field3]) SELECT [Field4], [Field5], [Field6] FROM [remote-database-name].[database2].dbo.[Table2]'
This may not be the correct syntax as its off the top of my head at the time.
Please bear in mind that this theory is untested and is open to comments from more experienced SQL server database users ... it'll help me.
Thanks
Steve.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top