SELECT TOP works fine for returning a limited result set but it does not offer an offset option. To achieve an limit and offset that behaves like MySQL's hand LIMIT O, L parameters you will write a T-SQL stored procedure using a cursor. Here is the necessary code for the SP:
/*
LimitSelect is a used for returning a query result set with a limit and an offset.
Syntax:
LimitSelect query, offset, limit
Example:
LimitSelect 'Select * From users', 10, 5
This call would return 5 rows starting from the 10th row
Notes:
For offsets, the first row of the set is zero.
*/
CREATE PROCEDURE LimitSelect
@query CHAR (128), -- SQL query, it'd better be a SELECT!
@ INT, -- limit the result set of the query
@offset INT -- start result set from offset
AS
-- Execute call to declare a global cursor (node_cursor) for the query passed to the SP
EXEC ('DECLARE node_cursor CURSOR GLOBAL SCROLL READ_ONLY FOR ' + @query)
-- open the global cursor declared above
OPEN node_cursor
-- tweak the starting values of limit and offset for use in the loop
SET @offset = @offset + 1
SET @limit = @limit - 1
-- advanced the cursor to the offset in the result set
FETCH ABSOLUTE @offset FROM node_cursor
-- counter i
DECLARE @i INTEGER
SET @i = 0
-- loop until limit reached by counter i
WHILE (@i < @limit)
BEGIN
-- fetch the next row in the result set and advance counter i
FETCH NEXT FROM node_cursor
SET @i = @i + 1
END
-- clean finish
CLOSE node_cursor
DEALLOCATE node_cursor