November 6, 2008 at 8:18 pm
Dear all,
I have a database in SQL 2005 Std. Ed. cluster,
its status is (In Recovery / Read-Only ), I want to drop it and then re-attach it, but I have tried all of the following actions and failed :
Detach
Resotre Database DB001 WITH RECOVERY
Drop
Take Offline
It always said some bodies in use, but sp_who2 told me nobody was holding this db.
How I can drop this DB ? Please help me.
November 7, 2008 at 7:22 am
Hi,
If you right-click the database and choose Detach you are given the option to disconnect all users, can you do that?
Run
SELECT rsc_dbid, rsc_type, req_spid
FROM syslockinfo
WHERE rsc_dbid = yourdatabasename
to find out who is holding a lock (you can also run sp_lock but the output can be enormous on a busy server. at least you are limited to the output from a single database with the above query).
HTH!
/Elisabeth
elisabeth@sqlserverland.com
MCITP | MCT
http://sqlblog.com/blogs/elisabeth_redei/
http://linkedin.com/in/elisabethredei
November 7, 2008 at 11:10 am
Run the below mentioned code(on under database) to kill all connections to this database and then drop the database:
DECLARE @DatabaseName nvarchar(50)
SET @DatabaseName = N'Enter DB Name here'
DECLARE @sql varchar(50)
SET @sql = ''
SELECT @sql = @sql + 'Kill ' + Convert(varchar, SPId) + ';' FROM MASTER..SysProcesses WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId
SELECT @sql
EXEC(@SQL)
Go
DROP Database 'Enter DB Name here''
HTH
MJ
November 7, 2008 at 12:20 pm
I think for the database In Recovery status no user can connect to them.
So there will be other problem in deleting the Database.
Have tried by right click on database and delete option ?
Thanks
Thank You.
Regards,
Raghavender Chavva
November 7, 2008 at 1:46 pm
Is the database in Recovery /Pending mode?
SELECT state_desc FROM sys.databases WHERE name = YourDatabase
Then you have to set it in Emergency mode:
ALTER DATABASE YourDatabase SET EMERGENCY
HTH!
/Elisabeth
elisabeth@sqlserverland.com
MCITP | MCT
http://sqlblog.com/blogs/elisabeth_redei/
http://linkedin.com/in/elisabethredei
November 8, 2008 at 4:47 am
onlo (11/6/2008)
It always said some bodies in use, but sp_who2 told me nobody was holding this db.
ALTER DATABASE < DB name > SET OFFLINE WITH ROLLBACK IMMEDIATE
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 9, 2008 at 7:20 pm
Thank every bodies, I fixed the problem by re-install the whole SQL Server 2005.
Thanks a lot, your information is very very useful.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply