SQL SERVER – 2005 – A Simple Way To Defragment All Indexes In A Database That Is Fragmented Above A Declared Threshold

Just a day ago, I received email from regular reader Rajiv Kayasthy about a script which demonstrates the A Simple Way To Defragment All Indexes In A Database That Is Fragmented Above A Declared Threshold. He found this script on TechNet BOL and was attempting to run on SQL Server…
Read More

SQL SERVER – How to Retrieve TOP and BOTTOM Rows Together using T-SQL

Just a day ago, while working with some inventory related projects, I faced one interesting situation. I had to find TOP 1 and BOTTOM 1 record together. I right away that I should just do UNION but then I realize that UNION will not work as it will only accept one ORDER BY clause. If you specify more than one ORDER BY clause. It will give an error. Let us see how we can retrieve top and bottom rows together.

Read More

SQL SERVER – 2005 – FIX: Error message when you run a query against a table that does not have a clustered index in SQL Server 2005: “A severe error occurred on the current command”

In SQL Server 2005 while testing Indexes I had created a table with one non clustered index only. I did not create any clustered index on table. After that I ran SELECT statement, it gave me following error. I was very surprised when I looked at error. It says Msg…
Read More