Aug 11, 2001 #1 wuwang Programmer May 16, 2001 48 US Hi, I want to grab the first 50 records from the table. Why this code doesn't work? declare @COUNT INTEGER SELECT @COUNT = 0 WHILE @COUNT <= 50 BEGIN select MIN(TABLE_ID) from TABLE @COUNT = @COUNT + 1 END Thanks for your help.
Hi, I want to grab the first 50 records from the table. Why this code doesn't work? declare @COUNT INTEGER SELECT @COUNT = 0 WHILE @COUNT <= 50 BEGIN select MIN(TABLE_ID) from TABLE @COUNT = @COUNT + 1 END Thanks for your help.
Aug 11, 2001 #2 fluteplr Programmer Oct 23, 2000 1,599 US Because sql does not work that way. SQL 2000 select top 50 table_id from table order by table_id desc sql 7 set rowcount = 50 select table_id from table order by table_id desc set rowcount = 0 make sure you reset the rowcount or all your queries will return 50 rows max. btw. Even is sql did work the way you wanted it to your code would return the first table_id 50 times not the first 50 table_id(s) Upvote 0 Downvote
Because sql does not work that way. SQL 2000 select top 50 table_id from table order by table_id desc sql 7 set rowcount = 50 select table_id from table order by table_id desc set rowcount = 0 make sure you reset the rowcount or all your queries will return 50 rows max. btw. Even is sql did work the way you wanted it to your code would return the first table_id 50 times not the first 50 table_id(s)