开发者

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

开发者 https://www.devze.com 2023-03-15 09:14 出处:网络
is it possible to do 开发者_StackOverflow社区something like select * from [anotherserver].somedatabase.dbo.employee

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

精彩评论

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