OPENQUERY HELP

  • Here is my query:

    Select * from OPENQUERY(SERVERNAME,'SELECT *FROM TABLE1')

    My windows username (with domain) has been set to map to the linked server's administrator username and password.

    I can run this no problem so can others who have their username set up the same way.

    However I have an excel macro (which uses the above query) which I want others in the company to run. Adding all their usernames to the linked servers is out of the question.

    So what I have done is to set up a login on management studio called Other_USERS. This has been set to map to the administrator username and password of the linked server (exactly in the same way as my windows login).

    This username together with password has been hardcoded into the macro.

    Howevere when I login to Management studio using my login and try the following:

    SETUSER 'Other_USERS'

    Select * from OPENQUERY(SERVERNAME,'SELECT *FROM TABLE1')

    it fails with the following:

    Msg 15274, Level 16, State 1, Line 1

    Access to the remote server is denied because the current security context is not trusted.

    Any help would be much appreciated.

    Thanks

  • SETUSER is deprecated, and apparently does not work as well as its replacement. This will work: EXECUTE AS LOGIN = 'Other_USERS'

    Use REVERT to return to initial security context.

  • Brilliant thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply