connecting and changing user

  • Hi,

    I am writing an insert/update trigger. Based on the value I need to do the following:

    1. Connect to a different database(Same Server) and update a table

    2. Connect to a different server, (Same network/Domain, not a linked server) and update a table

    Username and passwords are different on all three servers and would like to keep that way. I tried CONNECT TO without success.

    What is the bestway to open a connection as a specific user, do the update and then close the connection.

    Thank you in advance.

  • I think, I got it. As soon as I posted my question, I thought of OPENDATASOURCE. 
    Here is the syntax if someone else requires it. 
    SELECT * FROM OPENDATASOURCE('SQLOLEDB','Data Source=ServerName;User ID=MyUID;Password=MyPass').Northwind.dbo.Categories
    I think this will work for both scenarios. Anybody else have any additional thoughts? 
    Thanks. 
     
     

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

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