473,378 Members | 1,119 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

copy data from one server to another

Hi all

is there a simple command where I can just copy some data from one
database server to another?
For example, lets say i have two servers that have the same table
called "States"
If I have all the state names in server1 but want to copy the all the
data to Server2, how would I write a command for this?

INSERT INTO [server2].[database2].states
SELECT statename FROM [server1].[database1].states

I have tried this but it gives me an error saying

"Invalid object name [server1].[database1].states"
"Invalid object name [server2].[database2].states"
Do I need a use [database] somewhere?

thanks
Harry

Nov 9 '08 #1
2 21599
On Sun, 9 Nov 2008 12:42:40 -0800 (PST), Dev guy wrote:
>Hi all

is there a simple command where I can just copy some data from one
database server to another?
For example, lets say i have two servers that have the same table
called "States"
If I have all the state names in server1 but want to copy the all the
data to Server2, how would I write a command for this?

INSERT INTO [server2].[database2].states
SELECT statename FROM [server1].[database1].states

I have tried this but it gives me an error saying

"Invalid object name [server1].[database1].states"
"Invalid object name [server2].[database2].states"
Do I need a use [database] somewhere?
Hi Harry,

You forgot one part in the qualification of the object names: the
schema. If the tables are in the default schema, you can omit the schema
name but you still need the extra dot, otherwise SQL Server will take
[datebase1] to be the schema and [server1] to be the database.
INSERT INTO [server2].[database2]..states
SELECT statename FROM [server1].[database1]..states

The above (note the extra dots) should work.

However, depending on the amount of data, you might want to try if you
can't copy over the data faster using SSIS.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Nov 9 '08 #2
Dev guy (ho*************@gmail.com) writes:
is there a simple command where I can just copy some data from one
database server to another?
For example, lets say i have two servers that have the same table
called "States"
If I have all the state names in server1 but want to copy the all the
data to Server2, how would I write a command for this?

INSERT INTO [server2].[database2].states
SELECT statename FROM [server1].[database1].states

I have tried this but it gives me an error saying

"Invalid object name [server1].[database1].states"
"Invalid object name [server2].[database2].states"
Do I need a use [database] somewhere?
In addition to Hugo's post, you must also define the remote server
with sp_addlinkedserver. If this is another SQL Server, this may be
as easy as saying:

sp_addlinkedserver 'Server1'

Note that there is no need to specify the server name for the local
server. That assuming that you are on server2 and in database2,
this should be sufficient:

INSERT states (statecode, statename)
SELECT statecode, statename
FROM server1.database1.dbo.states
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Nov 9 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: sbh | last post by:
I need to copy data from a table on one Oracle server to another. Scenario: Need to create a stored procedure in server a, database aa that will copy data from server b, database bb, table bbb to...
0
by: Banx | last post by:
Hi everyone, i'm trying to copy data from a table in Pervasive database to a table in MySQL Does anyone know how to do it? :confused: Is it posible to copy data from another database prog to...
5
by: Daniel Tan | last post by:
Are there anyway to copy rows of records from one query to another query and then hide the records in source query ? Pls advise. Thanks. Regards, Daniel
3
by: islandfong | last post by:
I am trying to copy data from one schema to another schema using TOAD connecting to Oracle 10i. Some of the tables can be copied smoothly but two some of them cannot. There is no error message given,...
3
by: colleen1980 | last post by:
Hi: Can any one please help me when user select 2 dates from DDLDate1 10/09/2006 and DDLDate2 10/12/06 and the name and it close the form. I need to create multiple records in the another table on...
2
by: nosipho | last post by:
Hello guys, I need to copy a database in SQL 2000 to another SQL2000 server. I tried backing up the database to a folder then restore it but it's not happening. Please help to know how to copy...
2
by: isa | last post by:
Hello everyone, i want to transfer/copy data from MSDE to SQL Server 2000 and from SQL Server to MSDE, through Stored Procedures , not using a "Replication", kindly tell me how i make a SP for...
1
by: diSangro | last post by:
I need to transfer data from one machine to another , both have HP UX B.10.20 with same usr settings. Data to be transferred are used by Unify data server r.6.1 , installed on both these...
3
by: waldek | last post by:
Hi, I'm trying to handle data passed to Py Callback which is called from C dll. Callback passes data to another thread using Queue module and there the data are printed out. If data is...
1
by: MicMic | last post by:
I have a field called HyperlinkCopy and on exit I want the data in that field to be copied into ViewCertificate. Thanks
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.