SQL 语句还原SQL Server数据库
生活随笔
收集整理的這篇文章主要介紹了
SQL 语句还原SQL Server数据库
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*
斷開所有用戶打開的連接
*/
use master--一定要有這個
goif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_killspid]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[p_killspid]
GOcreate proc p_killspid--創建存儲過程
@dbname sysname --要關閉進程的數據庫名
as
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
go--用法
exec p_killspid 'lq4'--調用存儲過程 這里的hj為數據庫名--恢復數據庫.
RESTORE DATABASE hj FROM disk='d:\LQ_db_201112020200.BAK' --備份數據的位置--完成后,刪除存儲過程drop proc p_killspid
轉載于:https://www.cnblogs.com/OOAbooke/archive/2011/12/05/2276527.html
總結
以上是生活随笔為你收集整理的SQL 语句还原SQL Server数据库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: magento tab(easy tab
- 下一篇: org.apache.commons.i