Select "Request" with a user name and password

I want to get table information from another server database.

Request type 'Server2

I already linked the server

Select * from server2.database1.dbo.table1 

Showing login failed for user sa

Any other alternative request to pass the password in the selected request.?

as

 Select * from server2.database1.dbo.table 'sa' 

Any suggestion of help ...?

+4
source share
2 answers

There is no alternative for a linked server, but you can use OPENROWSET , which accepts a server / user / password

+2
source

I think the username / password is for your linked server when configuring the link. After you issue a request to the linked server, this username / password will be used. Make sure that the account you used to configure the link has access to the data source of your database.

You can also try using OPENDATASOURCE to access the remote server, although if I remember correctly, it is slower than using the linker server. It accepts a username / password parameter, so you must include it in your SELECT query.

MSDN contains several examples of how to use it.

+2
source

Source: https://habr.com/ru/post/1392839/


All Articles