Solved

SQL 2005 active database

Posted on 2014-12-18
2
70 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 33

Accepted Solution

by:
ste5an earned 500 total points
ID: 40506758
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 47

Expert Comment

by:Vitor Montalvão
ID: 40506786
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql Audit table 3 66
Bubble user-defined Sql RAISERROR(...) to c# exception 14 167
SQL query with cast 38 42
Addition to SQL for dynamic fields 6 38
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
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 Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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