How to Skip the first 5 records and display the rest using Offset Clause of Denali?

Rajnilari2015
Posted by Rajnilari2015 under Sql Server category on | Points: 40 | Views : 1153
Let us first create the environment

-- Declare a table variable
DECLARE @T TABLE
(
[ID] INT
,[Name] Varchar(50)
)

-- Populate some data to the table
INSERT INTO @T
SELECT
Number
,'Name' + CAST(Number AS VARCHAR)
FROM master..spt_values
WHERE Type = 'p'
AND Number BETWEEN 1 AND 100

--Display the records
SELECT * FROM @T


Now execute the below query

SELECT * FROM @T 
ORDER BY [ID]
OFFSET 5 ROW


Partial Result
ID	Name
11 Name11
12 Name12
13 Name13
14 Name14
...........................
...........................
100 Name100

Comments or Responses

Posted by: Snaini on: 10/7/2015 Level:Starter | Status: [Member] | Points: 10
Good when we are using offset ,sql will skips first five.
Generally Offset is set to 0 by default, now we are changing . am I correct

Login to post response