Today, when writing a program, you need to generate an SQL statement from the start ID to the end ID. It turns out that you don't need this feature now.
How do you query SQL Server for data SQL statements that are queried between the first few to several in the database?
For example, in SQL Server, how do I query the data SQL statements from 10th through 30 in the database?
------Solution--------------------
Select top * from table where ID in (select Top ID from table order by ID) desc
------Solution--------------------
If there is a unique column that can use LS's
Select Identity (int,1,1) id,* into the temp from table
SELECT * from temp where ID between and 30
------Solution--------------------
Select top * from table where identity field not in (select Top 9 identifies field from table)
------Solution--------------------
1
Select Top * FROM table
where ID not in (select Top ID from table order by ID)
ORDER BY ID
2--should start from 11.
SELECT * FROM table where ID between 30