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
 General SQL Server Forums
 New to SQL Server Programming
 copying table data across servers/instances

Author  Topic 

pwvailla
Starting Member

31 Posts

Posted - 2010-10-06 : 13:10:28
I am trying to copy table data from one SQL Server 2005 database (GPO_PC) residing on a development server into another database on my local PC called (GPO_LOCAL).

I would think the syntax would be something like:

select * into [gpo_local].[dbo].ossp_unit
from [gpo_pc].[dbo].ossp_unit

However, I must somehow indentify (fully qualify) the servers where this data resides. The intent is that I will use this ability to repopulate my test data on a table by table basis rather than import/export an entire database and that I will also be able to include a WHERE clause to select specific rows of data for testing. (i.e. WHERE prj = '123')

Any thoughts on how to reference the correct servers?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-06 : 13:23:18
Check out linked servers.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

pwvailla
Starting Member

31 Posts

Posted - 2010-10-06 : 14:24:24
Well, I can move the data via the Tasks>IMPORT DATA wizard, but I am looking for a more flexible method such that I can run it as a script. I have yet to find an example of how servers are referenced in the syntax. Any examples you can share?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-06 : 14:52:08
They are referenced via the four-part naming convertion, but you must create the linked server first.

select * from SomeLinkedServer.db1.dbo.tbl1

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -