Posts

Showing posts from July, 2015

To check the status of the Database while restoring

if OBJECT_ID('tempdb..#tmp_Restores') is null begin SELECT  @@servername as ServerName  , r.command as [CMD_Type]  , r.start_time  , r.percent_complete  , dateadd(second, r.estimated_completion_time / 1000, getdate()) as est_completion_time  /* Remark: 1900-01-01 00:00:00.000 offset !!! */  , dateadd(ss, DATEDIFF(SS, r.start_time, getdate()), 0) as running_time_1900_01_01  , dateadd(ss, r.estimated_completion_time / 1000, 0) as est_time_to_go_1900_01_01  , dateadd(ss, DATEDIFF(SS, r.start_time, dateadd(second, r.estimated_completion_time / 1000, getdate())), 0) as est_elaps_time_1900_01_01  , es.login_name  , es.host_name  , r.wait_type  , r.wait_time  , r.wait_resource  , r.cpu_time  , r.total_elapsed_time  , r.reads  , r.writes  , r.logical_reads  , s.text as SQLStmt into #tmp_Restores FROM    ...