SQL Server: is it possible to get data from another SQL server without setting linked server?

蹲街弑〆低调 提交于 2021-02-16 20:47:31

问题


I need to do the following query (for example):

SELECT c1.CustomerName FROM Customer as c1
INNER JOIN [ExternalServer].[Database].[dbo].[Customer] as c2
ON c2.RefId = c1.RefId

For some security reason my client doesn't allow me to create a linked server. The user under whom I execute this query has access to both tables. Is it possible to make it work without using linked server? Thanks.


回答1:


You could use OPENROWSET, which'll require the connection info, username & password...

While I understand that the client believes that having an always-on connection to their data is risky, that's why you lock down the account. OPENROWSET means including the connection info in plain text.




回答2:


'Linked Server' is a very specific thing -- basically, a permanent connection between servers. I can think of all sorts of reasons not to want that, while at the same time having no problem with folks writing queries that combine data from the two different data sources.

Anyway, depending on your requirement -- if this is just for ad hoc querying, OPENROWSET is good if inside of SQL-Server, or if you want to do this in MS Access, just link to the two tables, and your Access query won't care that one comes from one server, and one comes from another.

Alternatively, with a web or windows front-end, you could indpendently query each table into a data object, and then build a separate query on top of that.

Http Endpoints...

WebServices...

There's a million ways. I wouldn't be so quick to assume, as @Lasse suggests, that any form of 'linking' this data together would make you some kind of rougue data linker.



来源:https://stackoverflow.com/questions/3373221/sql-server-is-it-possible-to-get-data-from-another-sql-server-without-setting-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!