开发者

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

is it possible to do 开发者_StackOverflow社区something like

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

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜