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 – Rules for Optimizining Any Query – Best Practices for Query Optimization
My quick rules for query optimization: a primary key, a clustered index, the right non-clustered indexes, fewer views and triggers, and other simple checks.
SQL SERVER – Difference Between Index Scan and Index Seek
What is the difference between Index Scan and Index Seek? I explain how SQL Server uses search predicates to decide which index operation a query gets.
SQL SERVER – Remove Duplicate Entry from Comma Delimited String – UDF
A simple UDF from reader Ashish Jain that removes duplicate entries from a comma delimited string by turning it into a table and using DISTINCT.
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 – Find Row Count in Table – Find Largest Table in Database – T-SQL
A quick script using sys.dm_db_partition_stats that lists the row count of every table and shows the largest table in database right at the top.







