SQL SERVER – 2005 – Last Ran Query – Recently Ran Query

How many times we have wondered what were the last few queries ran on SQL Server? Following quick script demonstrates last ran query along with the time it was executed on SQL Server 2005. SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query] FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest…
Read More

SQL SERVER – Difference Between Index Rebuild and Index Reorganize Explained with T-SQL Script

Index Rebuild : This process drops the existing Index and Recreates the index. USE AdventureWorks; GO ALTER INDEX ALL ON Production.Product REBUILD GO Index Reorganize : This process physically reorganizes the leaf nodes of the index. USE AdventureWorks; GO ALTER INDEX ALL ON Production.Product REORGANIZE GO Recommendation: Index should be…
Read More