locked
Efficient SQL Stored Procedure for asp.net paging only working with sql server 2012 RRS feed

  • Question

  • User325940419 posted

    Excellent Feature (OFFSET and FETCH)  of MS SQL Server 2012

    CREATE PROCEDURE FetchRow
    (
     @OffSetRowNo int,
     @FetchRowNo int
    )
    	
    AS
    
    SELECT ItemID,ItemName,Description FROM MDItem
    ORDER BY ItemID DESC
    OFFSET @OffSetRowNo ROWS
    FETCH NEXT @FetchRowNo ROWS ONLY
    GO
    
    
    output
    -------------
    ItemID   ItemName         Description
      
    1505	    Stone Chips	      good chips
    1504	    Shingles	      Notice
    1503     Filling-earth	      Idea
    1502	    5000 PSI	
    1501	    DF 10mm 72.5     Grade 	
    1498     Mellamine           Board	
    1494	    we4twert	      test  uopasd
    1492	    Facial Tissue	       fay
    1491	    Tissue	               bangla
    1490	    Mum Water	        water


    with this procedure you can define  how many rows you want to ignore and fetch.

    @OffSetRowNo this parameter define how many rows you want to ignore
    and
    @FetchRowNo this parameter define how many rows you want to fetch.

    Tuesday, October 16, 2012 12:38 PM

All replies

  • User1188500805 posted

    yes Here is the solution. I got it. many thanks

    Wednesday, October 17, 2012 3:24 AM
  • User-2043371897 posted

    Thanks

    Thursday, October 18, 2012 3:12 AM