Monday, 9 December 2013

Select nth row of a table in sql server

WITH myTableWithRows AS (
  SELECT (ROW_NUMBER() OVER (ORDER BY myTable.SomeField)) as row,*
  FROM myTable)
 SELECT * FROM myTableWithRows WHERE row = 3

where  myTable=your table name,
SomeField= your table column name,
row= name of internal primary key for run time only
myTableWithRows = self created table

Back Page

Search on This Blog