I really need some help; I need to declare dinamicly an number of records to be pulled out of the table.. so I need to declare first
DECLARE @NumberOfRecords int
then
DECLARE @i int
set @i=0
and
WHILE @i<@NumberOfReocords
begin
declare
@Record
set @i= @i+1
end
all the variables @NumberOfRecords, and the @Record

declare programaticly a X number of variables
Jarron
Fahmy
Hi Jayachandran
excellent, i am also interested but I am very much keen to know how can it(row sequence #) be generated in SQL server 2000 using query.
please help
thanks in advance
ChrisNewmanUK
allez
select top (select count(*) from tbl1) *
from tbl2
order by keycol;
You could also use row_number() or identity to generate a sequence number and then process rows based on it.
209732
Hi,
Can u tell is that equivalent to this query
select * from <table_name> order by column1 limit 0,10 -- iam taking top 10 records from the table.
But iam using this in query in a cursor and i will get the value (0,10) from the result set of an other query
Please Help, Iam new to MYSQL
Thanks,
Murali.V
Bender
-- fetches 1 to 10 rows sorted by keycol order
with paged_t
where rownum between 1 and 10;
-- fetches 11 to 20 rows sorted by keycol order
with paged_t
where rownum between 11 and 20;
Note that this doesn't guarantee that you will get distinct rows for each selection since it depends on other transactions against the table. If you are inserting new rows that can appear in the beginning, it is possible to get same row twice and so on. There are ways to avoid this but it will affect concurrency (using serializable isolation level for example). The scenario I described above is a paging scenario.
On the other hand, if you just need some N number of rows sorted by some column every time then you can just use the TOP clause in a SELECT statement. You can number the rows easily on the client-side.
-- @numrows is parameter to SP:
select top(@numrows) *
from tbl
order by keycol;
Rob Reiss
threna
Once again thank you