Kun fremad-markører tillader ikke baglæns scrolling. Den eneste rullemulighed, vi har, er FETCH NEXT.
Kun fremad statiske markører er ikke følsomme over for ændringer (opdatering, sletning, indsæt) foretaget i den originale datakilde, efter at markøren er oprettet.
Script for Forward_Only Static Cursor
--slip tabel dbo.CustomerCreate table dbo.Customer ( CustomerId Int Identity(1,1),CustomerName VARCHAR(100),StreetAddress VARCHAr( 100),City VARCHAR(100),State CHAR(2))go--Indsæt et par poster i Sample TableInsert into dbo.CustomerSelect 'Aamir shahzad','Test Street Address','Charlotte','NC'Union Select' M Raza','Test Street Address','Charlotte','NC'Select * fra dbo.Customer--Insert NEW RecordInsert into dbo.CustomerSelect 'John Smith','Test Street Address','New York City',' NY'--Slet RecordsDelete from dbo.CustomerWhere CustomerName in ('Aamir Shahzad','M Raza')--Update All RecordUpdate dbo.Customerset CustomerName='NO NAME'--Cursor ScriptDeclare @CustomerID INTDeclare @CustomerNAme (100) DECLARE @StreetAdd ress VARCHAR(100)DECLARE @City VARCHAR(100)DECLARE @State CHAR(2)--DECLARE A CURSORDECLARE CUR CURSORForward_Only StaticFORSelect CustomerID,CustomerName, StreetAddress,City,State from dbo.OPENCURPORRSIN' --FETCH NEXT RECORDFETCH NEXT FROM CUR INTO @CustomerID,@CustomerNAme,@StreetAddress,@City,@StateWHILE @@FETCH_STATUS=0BEGIN RAISERROR ('',0,1) MED NUWAITWAITFOR FORSINKELSE KONTAKT '15'0:@CustomerID,' ',@CustomerNAme,' ',@StreetAddress,' ',@City,' ',@State) FETCH NEXT FROM CUR INTO @CustomerID,@CustomerNAme,@StreetAddress,@City,@StateENDCLOSE CURDEALLOCATE CUR
Se videoen til Demo How Forward Only Static Cursors fungerer i SQL Server.