Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query Multiple Servers with Different Logins

Author  Topic 

kimharlan
Starting Member

9 Posts

Posted - 2007-08-13 : 10:45:02
Is it possible to query 2 different databases, residing on 2 different servers with different user credentials / SQL Login accounts for each, within the same SQL Stored Procedure, or even in-line? This is probably not possible, but I thought I would check. I am using .NET 2005 on the front end so I am guessing that I will probably need to create two different data sources in .NET, with different connection strings for each, and query each database individually, looping through the results to "add on" to my gridview dynamically. I was hoping for a more efficient way of doing this through SQL but I am guessing that it is not possible. The main issue is that the second database is managed by another department and our department won't want to share our account credentials with that department, which means I won't be able to use the same SQL login account for each database. Does this make sense at all? Does anyone know of any possible solutions? Thanks so much!

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2007-08-13 : 16:40:04
You can set up a linked server to the other department's sql server and use the provided credentials. Once it's set up (and assuming the credentials have proper access) you can use 4 part naming on your server within your stored procedure to access data on the other server.
Go to Top of Page

kimharlan
Starting Member

9 Posts

Posted - 2007-08-14 : 11:02:01
That's a great idea! Thanks! I don't know alot about linked servers but I am researching that now. I will have to see if I can get access to do that (on our server), as I currently am not able to even execute sp_addlinkedserver with my current permissions. Thanks again!
Go to Top of Page
   

- Advertisement -