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 2005 Forums
 Transact-SQL (2005)
 How to copy data from table to another table

Author  Topic 

satya068
Posting Yak Master

233 Posts

Posted - 2011-06-27 : 04:20:01
Hello Guys,
I would like to know the syntax for copying data from TABLE-A in one server to TABLE-B in another server.(two different sql servers)


Thanx






Satya

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-06-27 : 04:27:50
Like you would do it on the same server but using 'linked server'.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2011-06-27 : 04:34:41
Thanx for ur reply,

yes ,i am able to do that using export data,but could it be possible to do that using sql script?using sql script on same server where data present and distination in linked server?

Thanx

Satya
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-06-27 : 04:50:49
Sure. Once you have a linked server you can do it like this:
insert [linked server name].databasename.dbo.tablename(col1, col2, ...)
select col1, col2, ... from databasename.dbo.tablename


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

ching1874
Starting Member

11 Posts

Posted - 2011-06-27 : 04:52:40
using linked server will be ok for your requirement

insert into tableA select * from serverB.tableB
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2011-06-27 : 05:11:51
Thanx to both of you,
This is what i am looking for.


Satya
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-06-27 : 05:14:30
quote:
Originally posted by ching1874

using linked server will be ok for your requirement

insert into tableA select * from serverB.tableB


Please don't post WRONG examples
serverB.tableB isn't possible!

[server].[database].[schema].[table] is the correct way.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -