Thursday 19 September 2019

How to check execution progress of the T-SQL Commands or DBCC Commads

--Use Below query to check the progress of the DBCC commands like shrinking database files  
SELECT text, 
       Db_name(database_id) DBName, 
       estimated_completion_time, 
       percent_complete, 
       open_transaction_count, 
       * 
FROM   sys.dm_exec_requests DER 
       CROSS apply sys.Dm_exec_sql_text(DER.sql_handle) 
WHERE  command LIKE '%DBCC%' 
--OR command like ‘%BACKUP%’  
--OR command like ‘%SELECT%’  
--OR command like ‘%EXECUTE%’  
--OR command like ‘%INSERT%’ 



SELECT T.TEXT, * FROM SYS.sysprocesses SP 
 CROSS APPLY SYS.fn_get_sql (sp.sql_handle) T 
 --WHERE TEXT LIKE 
%INSERT%’ 

No comments:

Post a Comment