On Sat, 28 Aug 2004 23:08:43 +0200, Hugo Kornelis
[quoted text, click to view] <hugo@pe_NO_rFact.in_SPAM_fo> wrote:
>On Sat, 28 Aug 2004 10:41:29 +0100, Harag wrote:
>
>>On Fri, 27 Aug 2004 17:37:08 +0100, "Eduardo Greco"
>><eduardo@persocom.com.br> wrote:
>>
>>>Hi there...
>>>I want to show a specific row in my table, say, the 15th row. But I want to
>>>show only this row, not the previous rows.
>>>How to do it?
>>>Using SQL Server 2000.
>>>Thank you.
>>> Eduardo
>>>
>>
>>
>>As the other 2 say, there is no such things as rows in a RMDB.
>>
>>checkout
>>
>>
http://aspfaq.com/show.asp?id=2427 >>
>>
http://aspfaq.com/show.asp?id=2120 >>
>>the second one I pointed you to is mainly for the very bottom method
>>of paging rows (which I'm sure you might ask one day) by Chris Hohmann
>>(i know this isn't a paging problem you got) but the way he reads the
>>rows is an alternative to the other 2 options given here by Itzik &
>>Anith.
>>
>>
>>CREATE PROCEDURE GetMemberRow(@RowID INT = 1)
>>AS
>> DECLARE @id INT
>>
>> SET ROWCOUNT @RowID
>> SELECT @id = MemID
>> FROM YourTable
>> ORDER BY MemID
>>
>> SET ROWCOUNT 1
>> SELECT MemID, MemName
>> FROM YourTable
>> ORDER BY MemID
WHERE MemID = @id
[quoted text, click to view] >>GO
>>
>>
>>
>>Not sure if the above would be any faster than the other methods as
>>I'm still a "noob" and learning.
>>
>>If any guru thinks the above is wrong (or way toooooo slow) then
>>Please let me know.
>>
>>HTH
>>
>>Al
>
>Hi Al,
>
>I think the last query misses a WHERE clause:
> WHERE MemID = @id
Correct, Doh! thanks for pointing that out.
[quoted text, click to view] >Otherwise, I don't see how this procedure will ever return anything other
>than the row with the lowest MemID.
>
>If that is added, than this can be a quick way to find and return the row
>with the n-th lowest MemID, but only if MemID is the primary key of the
>table.
Yea, it would depend on what the "Order BY" clause is on, eg MemAge,
MemName etc. but as you say the PK is the key to search/sort on
[quoted text, click to view] >
>Oh, and SET ROWCOUNT 1 isn't necessary either.
yea, in this case it isn't necessary. I was just mainly converting
Chris' Rowcount paging proc so left in the rowcount 1 to show the OP
which part of the proc its from, or the idea that the #1 could be
changes to a variable and that he could get the next X (3) members
after the 15th.
[quoted text, click to view] >
>Best, Hugo