The BOL script to defragment all indexes in a database above a declared threshold failed with Msg 2501. I fixed the missing schema prefix so it runs on SQL Server 2005.
SQL SERVER – How to Retrieve TOP and BOTTOM Rows Together using T-SQL
Need TOP 1 and BOTTOM 1 in one result? UNION fails with two ORDER BY clauses. Here is a simple T-SQL way to retrieve TOP and BOTTOM Rows together.
SQL SERVER – Dynamic Case Statement – FIX : ERROR 156 : Incorrect syntax near the keyword
Using CASE in ORDER BY to switch between ASC and DESC gives Error 156: Incorrect syntax near the keyword. I show two ways to write a dynamic case that works.
SQL SERVER – How to Escape Single Quotes – Fix: Error: 105 Unclosed quotation mark after the character string
Jr. Developer asked me other day how to escape single quote?
User can escape single quote using two single quotes (NOT double quote).
SQL SERVER – Msg: 2593 : There are ROWCOUNT rows in PAGECOUNT pages for object ‘OBJECT’.
DBCC shows Msg 2593: There are ROWCOUNT rows in PAGECOUNT pages for object. It is harmless and for information only. Here is what it means.
SQL SERVER – FIX : ERROR : Cannot find template file for new query (C:\Program Files\Microsoft SQL Server\90\Tools\ Binn\VSShell\Common7\ IDE\sqlworkbenchprojectitems\Sql\ SQLFile.sql)
Cannot find template file for new query means SSMS lost a small local file. Where it lives, how to restore it, and what to check next.
SQL SERVER – FIX : ERROR : The query processor could not start the necessary thread resources for parallel query execution
What to do when the query processor could not start the thread resources for parallel query execution, and why this error often clears itself.







