вторник, 23 июня 2009 г.

SQL-ссылки (постраничный вывод)

постраничный вывод
http://www.arbinada.com/main/node/463

победитель (но если рассматривать все решения то CLR будет лучше)
DECLARE @handle int, @rows int;

EXEC sp_cursoropen
@handle OUT,
'SELECT O.* FROM orders O INNER JOIN customers C ON O.customer_code = C.customer_code
WHERE C.country_code = ''IT''
ORDER BY O.product_code ASC, O.customer_code ASC, O.order_type ASC, O.qty_date ASC',
1, -- Keyset-driven cursor
1, -- Read-only
@rows OUT SELECT @rows; -- Contains total rows count

EXEC sp_cursorfetch
@handle,
16, -- Absolute row index
400001, -- Fetch from row
100000 -- Rows count to fetch

EXEC sp_cursorclose @handle;

update!
сравнительный анализ

Комментариев нет: