Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2006
    Posts
    26

    Unanswered: rownum alternate in MS-SQL

    I want to get 100 rows from particular record and onward. in oracle i can use rownum and in mySql i have function limit ... i want to know what is the ms-sql alternate for it.

    I want to get 100 rows onward to one particular data ... how can i ?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    This doesn't sound like a good idea... (using rownum)
    Please enlighten me with the SQL you used in mySQL?
    Also, what version of SQL Server are you using?
    Last edited by gvee; 07-17-07 at 08:51.
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    SELECT TOP n

    (Being deprecated for modification statements in SS 2008+)
    SET ROWCOUNT = n

    (SS 2005)
    OVER () clause
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by hYph3n
    I want to get 100 rows from particular record and onward.
    You need more than just TOP, don't you?
    I don't like the use of rownum - I'm sure there's a better way to get what the OP wants!
    George
    Home | Blog

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by georgev
    You need more than just TOP, don't you?
    yes, a WHERE condition, too

    oh, and an ORDER BY clause, without which TOP is meaningless

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Quote Originally Posted by hYph3n
    I want to get 100 rows from particular record and onward. in oracle i can use rownum and in mySql i have function limit ... i want to know what is the ms-sql alternate for it.

    I want to get 100 rows onward to one particular data ... how can i ?

    ummmmmmmmmmmmmm

    what particular row
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Brett Kaiser
    what particular row
    the one specified by the WHERE condition
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  8. #8
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by Brett Kaiser
    ummmmmmmmmmmmmm

    what particular row
    That row, right there near the middle of my screen.

    -PatP

  9. #9
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I'm feeling better now
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  10. #10
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    "Standard" for SQL 2005:
    Code:
    with cte
    as
    (select row_number () over (order by name) as num, object_id, name
    from master.sys.tables)
    
    select *
    from cte
    where num >= 4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •