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
 General SQL Server Forums
 New to SQL Server Programming
 Using two dbs

Author  Topic 

timsmith
Starting Member

11 Posts

Posted - 2008-08-05 : 12:53:12
Hi,

I have two MS SQL Server 2005 databases. One of them is online and I connect to them using a.b.c.d (IP addresses). The other one is on my local machine, and I just attach the data files to access it.

I want to use tables from both of them, but can't work out how. If I have 2 dbs (say, db1 and db2) on my local machine, I use 'db1.dbo.table1' and 'db2.dbo.table1' to access the two tables, but I can't figure out how to do it if I connect to one of the dbs, and the other db is local.

Is there a way I can solve this?

thanks!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-05 : 12:57:39
You'll need to add a linked server to be able to query remote objects via T-SQL.

But you can do it from your application with two connection strings.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

timsmith
Starting Member

11 Posts

Posted - 2008-08-05 : 14:35:59
Thanks Tara. I found a link for installing the linked server at: http://msdn.microsoft.com/en-us/library/ms186466.aspx

I put in a.b.c.c\name as the linked server name as given in the instructions. In the connections properties, I also specified the login and pwd. However, I can't check it. The documentation says that by right clicking the link server, a 'Test Connection' option would be there, but I don't see it.

Any ideas on what I am doing wrong?

Also, I didn't understand what you meant by 'two connection strings'...sorry, a novice here..!
Go to Top of Page
   

- Advertisement -