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.
Author |
Topic |
lpozdol
Starting Member
6 Posts |
Posted - 2011-11-08 : 15:51:21
|
I recently attached a database from a bad backup. It attached, but had consistency errors. I since restored from a good backup. My problem is I cannot drop the bad database because of a 'ghost cleanup" process on it. I tried bouncing mssql and the server. All I need to do if to get rid of this database. Any Ideas? |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-11-09 : 05:03:00
|
Try a restore of another small database over the top of it.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
vikki.seth
Yak Posting Veteran
66 Posts |
Posted - 2011-11-09 : 06:06:34
|
try putting the db in single user mode before dropping or restoring a small dbalter database bad_db set single_user with rollback immediate. |
|
|
lpozdol
Starting Member
6 Posts |
Posted - 2011-11-09 : 10:04:50
|
thanks all! I will try these suggestions. I also am thinking on cleaning it up though checkdb. But something tell me it should not be that complicated. |
|
|
johntech
Yak Posting Veteran
51 Posts |
Posted - 2011-11-28 : 10:12:36
|
Make sure you don't have dependencies like database snapshots on the db you want to remove. Though, the error message would look otherwise. Are you sure that there is no hidden process that is connecting to your database? A good approach would be to run a script which kills all sessions and immediately after rename the database to another name and then drop database.First could you stop gost proceess or not ?orcreate a cursor based on this select: select d.name , convert (smallint, req_spid) As spid from master.dbo.syslockinfo l, master.dbo.spt_values v, master.dbo.spt_values x, master.dbo.spt_values u, master.dbo.sysdatabases d where l.rsc_type = v.number and v.type = 'LR' and l.req_status = x.number and x.type = 'LS' and l.req_mode + 1 = u.number and u.type = 'L' and l.rsc_dbid = d.dbid and rsc_dbid = (select top 1 dbid from master..sysdatabases where name like 'my_db')http://dba.stackexchange.com/questions/2387/sql-server-cannot-drop-database-dbname-because-it-is-currently-in-use-but-n |
|
|
|
|
|