SQL Server limiting result set

Ali Ekber

Ranch Hand

Posts: 41

posted 10 years ago

I need to limit the result set coming from a SQL Server query. I can get the top 10 by SELECT TOP 10. But how do I get the rows from 11 to 20, for example? This is very easy in MySQL, but don't know the syntax for SQL server. Is this possible without stored procedures? Thanks.

Amy Medrat

Greenhorn

Posts: 15

posted 10 years ago

Hey Ali, I hope this would help

select * from tableName where rowid in (select rowid from tableName where rownum < 21 minus select rowid from tableName where rownum< 11)

medRat

Ali Ekber

Ranch Hand

Posts: 41

posted 10 years ago

Amy, what are rowid and rownum? Are they keywords in SQL server? I am getting syntax error for them.