Leon
Leon

Reputation:

I want to delete a SQL db. How can I tell if it is being used?

I have W2k3 SBS running SQL 2005. I want to delete a SQL db. How can I tell if it is being used?

Thanks.

Upvotes: 0

Views: 75

Answers (2)

RRUZ
RRUZ

Reputation: 136391

You can use

select db_name(dbid) [database],T0.* from master..sysprocesses T0 WHERE  db_name(dbid)='your database'

To see users and process connected to the database.

Upvotes: 2

Remus Rusanu
Remus Rusanu

Reputation: 294267

You let the server run for long enough to catch any activity, then you look into the last_user_xxx columns in sys.dm_db_index_usage_stats for tables in your database. Any SELECT or INSERT/UPDATE/DELETE on any table during the lifetime of a server process will leave its imprint on those columns.

Upvotes: 0

Related Questions