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
 which database is currently in use

Author  Topic 

ConnieXujuan
Starting Member

48 Posts

Posted - 2012-03-25 : 19:21:12
Hi folks,

there are two databases with the same name and one of them is currently in use by an application.

I was just wondering which meta data views I can use for figuring out which one is the one that is currently in use?

Thanks a lot!

Connie

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2012-03-26 : 01:41:40
Do you mean 2 databases with the same name on different SQL Server instances? Using sp_who2 - will display the current usage on a database. An alternative is to run a trace and using the Connections filter .

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

ConnieXujuan
Starting Member

48 Posts

Posted - 2012-03-26 : 02:12:44
Hi Jack,

Thanks a lot for that!

It was two databases with the same name on different servers. Only one of the databases is currently used by an application.

if I use sp_who2 it will give me a flood of information and it will be hard for me to find out the useful information. So I was just wondering are there any metadata views that are relevant to all applications?

Thanks a lot!

Connie
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-03-26 : 06:01:24
sp_who and sp_who2 derive their results from sys.dm_exec_sessions and sys.dm_exec_requests, which are Dynamic Management Views you can SELECT from. You would simply add a WHERE condition to limit to just the database/application/other conditions you're looking for.
Go to Top of Page

ConnieXujuan
Starting Member

48 Posts

Posted - 2012-03-27 : 01:20:21
Thanks!!

Is the ProgramName column showing the application that is using the database?

Connie
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-03-27 : 02:58:42
That's correct.
Go to Top of Page
   

- Advertisement -