Question

I tried to query another specific server many times, but i failed... I searched and i found out that the server must be linked with the other server in order to achieve what i want. Unfortunately is not in my hands to change that so my question is, if it is possible to query the other server by providing credentials. The server i want to query has SQL Server 2005 Service Pack 4 (9.00.5000) and the server i'm working on has SQL Server 2005 Service Pack 3(9.00.4035).

Thanks in advance.

Was it helpful?

Solution

Use OPENROWSET or OPENDATASOURCE instead. Both allow you to pass credentials. This is your best option if you are unable to use a linked server.

This example works if you are using SQL Server logins.

SELECT a.*
FROM OPENROWSET('SQLNCLI', 'SERVER=<servername>;UID=<username>;PWD=<password>',
   'SELECT FOO FROM FOO.BAR') AS a
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top