More on Returning a Subset of a Recordset

  • Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/jwiner/moreonreturningasubsetofarecordset.asp

  • lol - ok, nicely done. Somewhat more efficient than cursors 🙂

    Why don't you just build a table and then use a between? The following example is in T-SQL as it allows the handy table var (automatically cleared after sp exec)

    CREATE PROCEDURE getSubset (@start int, @end int) AS

    DECLARE @tblTemp TABLE (pID int,

    intData int,

    strData nvarchar(50))

    INSERT INTO @tblTemp

    SELECT /*insert main functionality of sp here*/

    SELECT *

    FROM @tblTemp

    WHERE pID between

    @start and

    @end

    ORDER BY intData

    Life's not difficult...enjoy it.

    Nood!e

  • Thanks for your feedback. Your approach is definitely a solid option. Many ways to skin a cat.

  • what happens when the field you order by on

    is null

    for many records

    for example :

    select top 10 custnum,custname from customers where custname >

    (select max(custname)  from customers ) A order by custname

     

    when you got many records where custname = null

    then the result is null

    resolve that please

     

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply