Solved

SQL 2005 active database

Posted on 2014-12-18
2
61 Views
Last Modified: 2014-12-22
I have two databases configured with similar names. An application on my network communicates with one of the databases. I want to identify which one without looking at the client side. Is there anything I can view in SQL 2005 that will tell me which one is the active one. thanks
0
Comment
Question by:Sid_F
2 Comments
 
LVL 32

Accepted Solution

by:
Stefan Hoffmann earned 500 total points
Comment Utility
No.

But you can use  
SELECT  C.session_id ,
        C.connect_time ,
        C.net_transport ,
        C.protocol_type ,
        C.client_net_address ,
        C.client_tcp_port ,
        C.local_net_address ,
        C.local_tcp_port ,
        C.connection_id ,
        C.parent_connection_id ,
        S.spid ,
        S.blocked ,
        S.status ,
        S.sid ,
        S.hostname ,
        S.program_name ,
        S.hostprocess ,
        S.cmd ,
        S.nt_domain ,
        S.nt_username ,
        S.net_address ,
        S.net_library ,
        S.loginame 
FROM    sys.dm_exec_connections C
        INNER JOIN sys.sysprocesses S ON C.session_id = S.spid;

Open in new window

to see who's connected to your database(s).
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
Comment Utility
I have two databases configured with similar names.
In the same instance? That's impossible.
Please clarify where those two databases are.

I want to identify which one without looking at the client side.
Assuming that the databases with the same name are in different instances, you need to connect to each instance and run the command sp_who2. This stored procedure returns all connections to the respective instance and has information about the user, application and the client computer that is connecting.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now