sqlserver 还原脚本:
Restore database {databasename} from disk = 'E:\{databasename}.bak' with replace;
后缀加个 STATS 5 表示 完成5%就print一下
sqlserver 查询还原的进度信息:
SELECT req.session_id, database_name = db_name(req.database_id), req.status, req.blocking_session_id, req.command, [sql_text] = Substring(txt.TEXT, (req.statement_start_offset / 2) + 1, ( ( CASE req.statement_end_offset WHEN - 1 THEN Datalength(txt.TEXT) ELSE req.statement_end_offset END - req.statement_start_offset ) / 2 ) + 1), CONVERT(nvarchar(50),req.percent_complete)+'%' 完成度, req.start_time 开始时间, DATEADD(ms, req.[estimated_completion_time], GETDATE()) 预估完成时间, wait_type, wait_time/1000/60 耗时_分钟 FROM sys.dm_exec_requests as req WITH(NOLOCK) CROSS APPLY sys.dm_exec_sql_text(req.sql_handle) as txt WHERE command IN ('BACKUP DATABASE', 'BACKUP LOG', 'RESTORE DATABASE', 'RESTORE LOG')