Learn T-SQL Commands with Samples
Skip Navigation Links
Skip Navigation Links.
Expand DatabaseDatabase
Expand TableTable
Expand ViewView
Expand Stored ProcedureStored Procedure
Expand Data FilteringData Filtering
Expand Data GroupingData Grouping
Expand JoinsJoins
Expand TriggerTrigger
Collapse CursorCursor
Expand OperatorsOperators
Expand ConstraintsConstraints
Expand FunctionsFunctions
Expand Conditional ProcessingConditional Processing
Expand LoopingLooping
Expand Error HandlingError Handling
Expand v.IMP Queriesv.IMP Queries
Expand XMLXML
Expand Query PerformanceQuery Performance
Expand QueriesQueries
Expand NormalizationNormalization
Expand CreateCreate
     

Fetch Absolute

 
      
----“ABSOLUTE” n returns the nth row From the Top, “ABSOLUTE” -n returns the nth row From the Bottom.
DECLARE myCursor CURSOR LOCAL KEYSET FOR SELECT Name FROM EMP DECLARE @nTop CHAR(10) DECLARE @nBtm CHAR(10) OPEN myCursor
---- Retrieve the 3rd row from the Top
FETCH ABSOLUTE 3 FROM myCursor INTO @nTop
---- Retrieve the 5th row from the Bottom
FETCH ABSOLUTE -5 FROM myCursor INTO @nBtm SELECT @nTop as 'I am 3rd Row from Top', @nBtm as 'I am 5th Row from Bottom' CLOSE myCursor DEALLOCATE myCursor