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 Administration
 how to switch between 2 connections?

Author  Topic 

allan8964
Posting Yak Master

249 Posts

Posted - 2012-03-15 : 13:07:32
Hi there,

I openened 2 conenctions in 1 management studio object explore window, But I can only access the database in one connection. Can I switch to any one I want to? Scenario as folowing:

In server1 connect to server2 and I can see 2 connections in object explore window. Now I can work on a table1 in db1 in server1 with use db1; go
But when I try to work on table2 in db2 in server2 with use db2; go I always got error: Database 'db2' does nto exist. Make sure ...
Some help plz .... Thanks in advance.

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-15 : 13:12:34
Ever use a linked server?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

allan8964
Posting Yak Master

249 Posts

Posted - 2012-03-15 : 13:52:50
server1 is local and server2 is in same domain and we can access via RDP.
Go to Top of Page

jeffw8713
Aged Yak Warrior

819 Posts

Posted - 2012-03-15 : 16:45:19
Open a new query window and connect to the other instance. You can have multiple query windows open - each connected to a different server (or same server).

Sounds like you want to be able to query 2 separate instances of SQL Server in the same query window. That is possible, but it gets a bit more complex. If that is what you want to do - then I suggest you read up on SQLCMD mode in SSMS which will allow you to change your connection as needed in a single editor window.

Or, you can look at setting up linked servers - if you need to join the data from both instances.
Go to Top of Page

alishaali
Starting Member

8 Posts

Posted - 2012-03-28 : 04:22:56
Register the both servers and write query to fetch data from that particular server2 .. refer usage of linked server , how it works
Go to Top of Page
   

- Advertisement -