How to see the last running query of another session based on its SPID, using @@SPID to find session IDs and DBCC INPUTBUFFER to read the query.
SQL SERVER – Reseed Identity of Table – Table Missing Identity Values – Gap in Identity Column
Deleted rows left a gap in an identity column for my developer. Here is how to reseed identity of a table so new rows keep the sequence without gaps.
Trace Flags Worth Knowing About
Review trace flags worth knowing about in current SQL Server, distinguish session, global, and startup scope, and verify each flag’s support.
SQL SERVER – Shrinking NDF and MDF Files – A Safe Operation
Is shrinking NDF and MDF files safe? A reader asked if it causes data loss. It does not, but I explain why shrinking them is often not a good idea.
SQL SERVER – 2008 – 2005 – Find Longest Running Query – TSQL – Part 2
An updated script to find the longest running query in SQL Server 2005 and 2008, with the divide by zero error fixed and time now shown in milliseconds.
SQL SERVER – Find Number of Rows and Disk Space Reserved – Using sp_spaceused Interesting Observation
sp_spaceused shows the row count of a table and the disk space reserved. Here is why its numbers looked wrong on AdventureWorks and how @updateusage fixed them.
SQL SERVER – 2008 – 2005 – Find Longest Running Query – TSQL
My company owner asked which query runs longest and I found no ready script, so I wrote one: the Longest Running Query with its average and maximum time.







