use master
go--在硬碟上建立備份裝置
exec sp_addumpdevice 'disk',mybackupfile,
'c:\mybackupfile.bak'
--刪除備份裝置
exec sp_dropdevice mybackupfile
--備份資料庫資料到臨時裝置
backup database northwind
to disk = 'c:\northwind.bak'
--完全備份資料庫到備份裝置
backup database northwind
to mybackupfile
--執行差異備份
backup database northwind
to mybackupfile
with differential
-- 備份日誌檔案到備份裝置
exec sp_addumpdevice 'disk',mybackuplog,
'c:\mybackuplog.bak'
backup log northwind
to mybackuplog
-- 備份日誌檔案到臨時備份裝置
backup log northwind
to disk = 'c:\mybackuplog.bak'
--從備份裝置還原資料庫
restore database northwind
from mybackupfile
--從備份檔案還原資料庫
backup database northwind
to disk = 'c:\northwindback.bak'
backup database northwind
to disk = 'c:\northwindback.bak'
with differential
restore database northwind
from disk = 'c:\northwindback.bak'
with file = 1,recovery
restore database northwind
from disk = 'c:\northwindback.bak'
with file = 2,recovery
--事務日誌還原
restore database northwind
from disk = 'c:\northwindback.bak'
with file = 1,norecovery
restore log northwind
from disk = 'c:\northwindlog.bak'
with file = 1,recovery
--時點還原
backup database northwind
to disk = 'c:\northwind.bak'
backup log northwind
to disk = 'c:\mybackuplog.bak'
restore database northwind
from disk = 'c:\northwind.bak'
with file = 1,norecovery
restore log northwind
from disk = 'c:\mybackuplog.bak'
with file = 1 ,stopat = '2006-4-7 9:54:00' ,recovery
用SQL語句備份SQL資料庫
備份資料庫的命令是 backup database test to disk c test with format,name full backup of mynwind 解釋如下 backup database test 這裡的test指的是資料庫名稱 to disk c test 這裡指名的資料...
SQL資料庫如何用SQL語句備份資料庫
時間戳不帶秒 substring replace replace replace convert varchar,getdate 120 1,12 備份語句 建立儲存過程 create proc dbo backup db as 定義變數 declare filename varchar 100 變...
SQL資料庫備份1 完整備份
完整備份 完整備份資料庫到物理備份裝置 backup database studb to disk e bak studb all.bak go 完整備份資料庫到邏輯備份裝置 backup database studb to bk bk e bak studb 邏輯備份.bak go 備份的驗證與校...