Tintin
Tintin

Reputation: 2973

Is is possible to do a query on another SQL server from one server

is it possible to do something like

select * from [anotherserver].somedatabase.dbo.employee

[anotherserver] is on same network as my current SQL server.

Upvotes: 2

Views: 82

Answers (2)

Etienne
Etienne

Reputation: 46

In sqlServer you can do :

SELECT *
FROM   OPENROWSET(
           'SQLOLEDB',
           'Server=yourServer;Uid=yourID;Pwd=yourPWD;Database=yourDB',
           'select somfield1,somefield2 from yourTable'
       ) AS alias

But you got to be really carefull with the quote character ( ' ), be sure you have a correct string.

Upvotes: 1

Conrad Frix
Conrad Frix

Reputation: 52645

Yes with linked servers see Linking Servers on MSDN and also this article on how to use sp_addlinkedserver

Upvotes: 4

Related Questions