1. restore database KLJY_juncsoft from disk= 'D:\kljy_2012_12_28.bak' with recovery
注意在还原时,进度一直显示0%,但是实际上确实是在还原中的。有点让人以为还原运行不正常的。
2. 无法删除数据库 "juncsoftDB",因为该数据库当前正在使用。
USE MASTER GO DECLARE @dbname SYSNAME SET @dbname = 'juncsoftDB' --这个是要删除的数据库库名 DECLARE @s NVARCHAR(1000) DECLARE tb CURSOR LOCAL FOR SELECT s = 'kill ' + CAST(spid AS VARCHAR) FROM MASTER..sysprocesses WHERE dbid = DB_ID(@dbname) OPEN tb FETCH NEXT FROM tb INTO @s WHILE @@fetch_status = 0 BEGIN EXEC (@s) FETCH NEXT FROM tb INTO @s END CLOSE tb DEALLOCATE tb EXEC ('drop database [' + @dbname + ']')
杀掉 要删除的 db 的进程,然后在 drop database xxx;