--完整備份
backup database northwindcs
to disk='g:\backup\northwindcs_full_20070908.bak'
--差異備份
backup database northwindcs
to disk='g:\backup\northwindcs_diff_20070908.bak'
with differential
--日誌備份,預設截斷日誌
backup log northwindcs
to disk='g:\backup\northwindcs_log_20070908.bak'
--日誌備份,不截斷日誌
backup log northwindcs
to disk='g:\backup\northwindcs_log_20070908.bak'
with no_truncate
--截斷日誌不保留
backup log northwindcs
with no_log
--或者
backup log northwindcs
with truncate_only
--截斷之後日誌檔案不會變小
--有必要可以進行收縮
--檔案備份
exec sp_helpdb northwindcs --檢視資料檔案
backup database northwindcs
file='northwindcs' --資料檔案的邏輯名
to disk='g:\backup\northwindcs_file_20070908.bak'
--檔案組備份
exec sp_helpdb northwindcs --檢視資料檔案
backup database northwindcs
filegroup='primary' --資料檔案的邏輯名
to disk='g:\backup\northwindcs_filegroup_20070908.bak'
with init
--分割備份到多個目標
--恢復的時候不允許丟失任何乙個目標
backup database northwindcs
to disk='g:\backup\northwindcs_full_1.bak' ,disk='g:\backup\northwindcs_full_2.bak'
--映象備份
--每個目標都是相同的
backup database northwindcs
to disk='g:\backup\northwindcs_mirror_1.bak'
mirror
to disk='g:\backup\northwindcs_mirror_2.bak'
with format --第一次做映象備份的時候格式化目標
--映象備份到本地和遠端
backup database northwindcs
to disk='g:\backup\northwindcs_mirror_1.bak'
mirror
to disk='\\192.168.1.200\backup\northwindcs_mirror_2.bak'
with format
--每天生成乙個備份檔案
declare @path nvarchar(2000)
set @path ='g:\backup\northwindcs_full_' + convert(nvarchar,getdate(),112)+'.bak'
backup database northwindcs
to--從norecovery或者
--standby模式恢復資料庫為可用
restore database northwindcs_bak
with recovery
--檢視目標備份中的備份集
restore headeronly
from disk ='g:\backup\northwindcs_full_20070908.bak'
--檢視目標備份的第乙個備份集的資訊
restore filelistonly
from disk ='g:\backup\northwindcs_full_20070908_2.bak'
with file=1
--檢視目標備份的卷標
restore labelonly
from disk ='g:\backup\northwindcs_full_20070908_2.bak'
--備份設定密碼保護備份
backup database northwindcs
to disk='g:\backup\northwindcs_full_20070908.bak'
with password = '123',init
restore database northwindcs
from disk='g:\backup\northwindcs_full_20070908.bak'
with password = '123'
ms sql手動備份
一 備份資料庫 1 開啟sql企業管理器,在控制台根目錄中依次點開microsoft sql server。2 sql server組 雙擊開啟你的伺服器 雙擊開啟資料庫目錄。3 選擇你的資料庫名稱 然後點上面選單中的工具 選擇備份資料庫。4 備份選項選擇完全備份,目的中的備份到如果原來有路徑和名稱...
MSSQL經典語句
1.按姓氏筆畫排序 select from tablename order by customername collate chinese prc stroke ci as 2.資料庫加密 select encrypt 原始密碼 select pwdencrypt 原始密碼 select pwdco...
MSSQL經典語句
1.按姓氏筆畫排序 select from tablename order by customername collate chinese prc stroke ci as 2.資料庫加密 select encrypt 原始密碼 select pwdencrypt 原始密碼 select pwdco...