This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
SQL SERVER - 2005 - Find Nth Highest Record from Database Table - Using Ranking Function ROW_NUMBER

SQL SERVER – 2005 – Find Nth Highest Record from Database Table – Using Ranking Function ROW_NUMBER

March 12, 2008
Pinal Dave
SQL Performance
MVP, SQL Function, SQL Joins, SQL Scripts

Nicholas Paldino shared a neat way to find the Nth Highest Record from a table in SQL Server 2005 using the ranking function ROW_NUMBER. Here is his query.

Read More
SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - Part 3

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

March 11, 2008
Pinal Dave
SQL Performance
SQL Function, SQL Joins, SQL Scripts

Part 3 on how to retrieve TOP and BOTTOM rows together: Dave Arthur’s solution uses UNION ALL instead of an OR clause, and it is quite good.

Read More
A blue maze to represent a SQL problem.

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

March 10, 2008
Pinal Dave
SQL Tips and Tricks
CTE, SQL Function, SQL Joins, SQL Scripts, SQL Server

Part 2 of retrieving TOP and BOTTOM rows together: a reader’s solution using a CTE, the temporary result set introduced in SQL Server 2005.

Read More
SQL SERVER - Find Nth Highest Record from Database Table

SQL SERVER – Find Nth Highest Record from Database Table

March 8, 2008
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts, SQL Server

Find the Nth Highest Record in a table with a correlated subquery on AdventureWorks. The example returns the 4th highest pay rate; change 4 to any number.

Read More
SQL SERVER - Simple Example of Cursor - Sample Cursor Part 2

SQL SERVER – Simple Example of Cursor – Sample Cursor Part 2

March 5, 2008
Pinal Dave
SQL Tips and Tricks
SQL Cursor, SQL Scripts

A reader asked me to update my Simple Example of Cursor with AdventureWorks. Here is a sample cursor that loops through ProductID and prints each one.

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

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

March 4, 2008
Pinal Dave
SQL Performance
SQL Error Messages, SQL Index, SQL Scripts, SQL Server DBCC

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.

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

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

March 2, 2008
Pinal Dave
SQL Tips and Tricks
SQL Error Messages, SQL Function, SQL Joins, SQL Scripts, SQL Server

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.

Read More
Previous 1 … 293 294 295 296 297 298 299 … 336 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com