2015-05-27 59 views
1

我有一個temp_table,它由80多行組成。 在aqua我不能做select *由於空間/內存限制我猜。如何做在特定的表上按範圍選擇查詢範圍

select * from #tmp 

有沒有辦法按範圍選擇查詢範圍?

例如: - 先給我10000條記錄,接着10000和接下來的10000條,直到最後。

注: -

1) I am using Aqua Data Studio, where I am restricted to select max 5000 rows in one select query. 

    2) I am using Sybase, which somehow doesn't allow 'except' and 'select top @var from table' syntax and ROWNUM() is not avaliable 

謝謝!

+0

你可以通過一個程序做到這一點。的 – Rahul

+0

可能重複[如何獲得N行從行M在T-SQL開始從排序表(http://stackoverflow.com/questions/758186/how-to-get-n-rows-starting-from-row -m-從排序表功能於T-SQL)的 –

+0

可能重複(http://stackoverflow.com/questions/7759166/sybase-offset-for-pagination) – rutter

回答

0

難道你們就不能使用類似與在表中的

select top n * from table where some_id > current_iteration_starting_point 

select top 200 * from tablename where some_id > 1 

和不斷增加的iteration_starting_point條款上的一些標識爲1的下一次迭代,因此說201上。

+1

,將永遠給頂'N'記錄,沒有一系列的M'和'N' –

0

您可以在SQL Server中使用類似下面的內容。只需爲每個新迭代更新@FirstRow。

declare @FirstRow int = 0 
declare @Rows int = 10000 

select top (@[email protected]) * from Table 
except 
select top (@FirstRow) * from Table 

set @FirstRow = @FirstRow + @Rows 

select top (@[email protected]) * from Table 
except 
select top (@FirstRow) * from Table 
+0

這是一個很好的解決方案之間'記錄,但在我使用的Sybase中不允許使用語法 – SRJ