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.
精彩评论