1

I have a local database, DB1, that I created and is connected to my web application. My web application takes in stored procedures from DB1 and queries them. My application connects to SQL Server using my Windows Authentication account.

I have access to another database, DB2, on a different server that I have read only access to using the same windows account. Can I still query from DB2 if my application is only connected to DB1?

When I execute stored procedures in DB1 that also query stuff from DB2 it works on SQL Server Management Studio but I get an error when I try to do it on my application.

  • DB2 is added as a linked server on DB1 already. I have stored procedures executing from DB2 within DB1 and it will execute but when I try to execute it on my application it will only execute stored procedures from DB1 if I try I stored procdure using DB2 I get an 500 error – KamSami Jan 28 at 20:14
  • 1
    This could be a "double hop issue". Are you seeing NT AUTHORITY ANONYMOUS logon errors in the sql server log? If so, look into adding the kerberos protocol (My go to is the kerberos configuration manager). – Randi Vertongen Jan 28 at 20:32
0

You need to add DB2 as a linked server on your DB1 instance. Once created, then you can specify [LinkedServer].[Database].[schema].[Table] to query the objects on that server. Other than linked servers, there is no other way for a connection to discover and connect to another server(even if you have access) for security reasons. If you create a linked server, you are specifying a connection that server DB1 can establish and query DB2, all from BD1, not from the client.

Hope that helps. How to create a linked server in MSSQL

  • Thanks for the answer! I already added a DB2 as a linked server to DB1 and my stored procedures are saved as [LinkedServer].[DB2].[schema].[Table] in DB1 and it will execute when I use sql management studio but not when I execute it on my application. – KamSami Jan 28 at 20:12
  • Ahh ok, what security context is the linked server using (Windows Auth?SQL Login Etc)? Is it the same one you are connecting to SQL Management Studio with? – WadeH Jan 28 at 20:16
  • The linked server is using windows auth. My windows account has permissions to DB2 if I try using a regular login that was created I don't have permision to execute from DB2. – KamSami Jan 28 at 20:22
  • Ok, the linked server account, needs to have the same access as your account to be successful. Get it the same level of access on the DB2 server and you should be good to go. – WadeH Jan 28 at 20:37
  • Thanks for the help! the thing is I was given access to DB2 as read-only on my windows account and I can't further it any higher than that. – KamSami Jan 29 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.