SQL Server Query page x, per page Y record

xiaoxiao2021-03-06  41

Query page x, per page Y record

The most basic processing method (principle):

If there is a primary key in the table (can be recorded without repetition), you can use the following method, of course, Y, (x-1) * y to replace the specific number, no variables:

SELECT TOP Y *FOM table Where master key NOT IN (SELECT TOP (X-1) * Y master key from table)

If there is no primary key in the table, you can use a temporary table, add the identification field. The x, y can use variables.

Select ID = Identity (int, 1, 1), * INTO #TB from WHERE ID BETWEEN (X-1) * y and x * Y-1

转载请注明原文地址:https://www.9cbs.com/read-71983.html

New Post(0)