How long time has taken for SQL Server database Backup or Restore?
<div class="MsoNormal" style="margin:0 0 8pt;">After restoring any database you can get information the time required for restoring database not before restoring </div>
<div style="text-align:left;"></div><div style="text-align:left;">select session_id,</div><div style="text-align:left;"></div><div style="text-align:left;">convert(nvarchar(22),db_name(database_id)) as [database],</div><div style="text-align:left;"></div><div style="text-align:left;">case command</div><div style="text-align:left;"></div><div style="text-align:left;">when ‘BACKUP DATABASE’ then ‘DB’</div><div style="text-align:left;"></div><div style="text-align:left;">when ‘RESTORE DATABASE’ then ‘DB RESTORE’</div><div style="text-align:left;"></div><div style="text-align:left;">when ‘RESTORE VERIFYON’ then ‘VERIFYING’</div><div style="text-align:left;"></div><div style="text-align:left;">when ‘RESTORE HEADERON’ then ‘VERIFYING HEADER’</div><div style="text-align:left;"></div><div style="text-align:left;">when ‘RESTORE HEADERONLY’ then ‘VERIFYING HEADER’</div><div style="text-align:left;"></div><div style="text-align:left;">else ‘LOG’ end as [type],</div><div style="text-align:left;"></div><div style="text-align:left;">start_time as [started],</div><div style="text-align:left;"></div><div style="text-align:left;">dateadd(mi,estimated_completion_time/60000,getdate()) as [finishing],</div><div style="text-align:left;"></div><div style="text-align:left;">datediff(mi, start_time, (dateadd(mi,estimated_completion_time/60000,getdate()))) - wait_time/60000 as [mins left],</div><div style="text-align:left;"></div><div style="text-align:left;">datediff(mi, start_time, (dateadd(mi,estimated_completion_time/60000,getdate()))) as [total wait mins (est)],</div><div style="text-align:left;"></div><div style="text-align:left;">convert(varchar(5),cast((percent_complete) as decimal (4,1))) as [% complete],</div><div style="text-align:left;"></div><div style="text-align:left;">getdate() as [current time]</div><div style="text-align:left;"></div><div style="text-align:left;">from sys.dm_exec_requests</div><div style="text-align:left;"></div><div style="text-align:left;">where command in (‘BACKUP DATABASE’,‘BACKUP LOG’,‘RESTORE DATABASE’,‘RESTORE VERIFYON’,‘RESTORE HEADERON’,‘RESTORE HEADERONLY’)</div><div style="text-align:left;"></div>