On Sun, 9 Nov 2008 12:42:40 -0800 (PST), Dev guy wrote:
Quote:
>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