tags:

views:

515

answers:

2

Hi,

Suppose, I have a database named testdb in test server. Also I have a database named proddb in prod server. Now I want to select data of a table of testdb database from proddb database.

How can I do that in SQL Server?

Also, I can do it using database link in oracle. But how can do that in SQL Server?

please help.

Thanks

Baju

+1  A: 

To do a cross server query, check out the system stored procedure: sp_addlinkedserver in the help files.

Once the server is linked you can run a query against it.

Mitch Baker
The tables are in different server.
Yep, looking that up right now. You can do it by linking the servers...
Mitch Baker
How can I link between to servers and how can I select data? please provide steps. thanks
+1  A: 

You need sp_addlinkedserver()

http://msdn.microsoft.com/en-us/library/ms190479.aspx

Example:

exec sp_addlinkedserver @server = 'test'

then

select * from [server].[database].[schema].[table]

In your example:

select * from [test].[testdb].[dbo].[table]
MatthieuF