Retrieving Specified Rows
Brian Moran's solution for retrieving specified rows (SQL Server Savvy: "Retrieving Specified Rows Within a Resultset," August 2001) was very interesting, but we often don't know which set of records we'll need (e.g., 11-20, 21-30, 31-40). Web Listing 1 (see "More on the Web" for download instructions) shows a code example that returns customers sorted by name from the Northwind database and lets you use parameters to specify which set of records you want. In the stored procedure call
_find(@first_record int, @return_records int)
@first_record is the first record number to be returned, and @return_records is the number of records (beginning with that first record) that you want returned.
I wrote my simple SQL example to help people see how creative use of subqueries can extend the functionality of TOP. But a generic solution for returning n records, starting from record Y, would be helpful. Your solution is a great start. However, the use of temporary tables might make this technique inefficient if you're looking for the last few records of a large resultset.
No Substitute for OLAP Coverage
I look forward to Russ Whitney's Mastering Analysis column every month. In fact, this column is the first thing I read when I receive my SQL Server Magazine, and I've memorized exactly where to find it in the magazine. However, in the October 2001 issue, you didn't have any articles about OLAP. Instead, you ran several articles about Microsoft .NET and XML. Although I recognize the importance of .NET and XML for SQL Server, and even recommend that you continue to run these articles, they are no substitute for the Mastering Analysis column and articles about data warehousing and OLAP.
We're sorry we didn't have the Mastering Analysis column for you in October; we gave Russ Whitney the month off. But never fear, Mastering Analysis is back in this issue with a look at local-cube MDX, page 65. We're also committed to continuing to make OLAP, data warehousing, and data mining an integral part of SQL Server Magazine's regular coverage. In this issue, we take a closer look at SQL Server 2000 Analysis Services' data-mining features in "Put Data Mining to Work," page 35.
The caption for Listing 1 in SQL Server Savvy: "Retrieving Specified Rows Within a Resultset," August 2001, should have been "Code to Return Rows 1-10." We regret any inconvenience this error might have caused.