SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


More on Returning a Subset of a Recordset


More on Returning a Subset of a Recordset

Author
Message
jwiner
jwiner
Old Hand
Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)

Group: General Forum Members
Points: 379 Visits: 18
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/jwiner/moreonreturningasubsetofarecordset.asp



MagneticNoodle
MagneticNoodle
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 1
lol - ok, nicely done. Somewhat more efficient than cursors Smile
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



jwiner
jwiner
Old Hand
Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)Old Hand (379 reputation)

Group: General Forum Members
Points: 379 Visits: 18
Thanks for your feedback. Your approach is definitely a solid option. Many ways to skin a cat.



ilan rosen
ilan rosen
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 2

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


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search