Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2003
    Posts
    1

    Question Unanswered: Sybase Select only 100 rows

    Hi All,

    I am new to Sybase. I would like to select only 100 rows from the Sybase using a single select statement.
    I should involve something like a row count. I tried using the function number(*) it just returns the number but i couldn't use it to manipulate the values in the where condition.

    Logically it should be like this "SELECT * FROM TABLE WHERE
    ROW_NUMBER BETWEEN 50 AND 150" Dont mind the Syntax given in here.

    Can u please help me how to do it.

    Thanks for taking time to read my message
    shyju

  2. #2
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606

  3. #3
    Join Date
    Feb 2003
    Location
    Thailand
    Posts
    42

    Cool Re: Sybase Select only 100 rows

    set rowcount 5
    go
    select name from sysobjects
    go

    name
    ----
    piak
    sysalternates
    sysattributes
    syscolumns
    syscomments

    ----------------------------------------------------------------

    set rowcount 0 --- return all
    go
    select name from sysobjects
    go


    name
    ----
    piak
    sysalternates
    sysattributes
    syscolumns
    syscomments
    sysconstraints
    sysdepends
    sysgams
    sysindexes
    syskeys
    syslogs
    sysobjects
    syspartitions
    sysprocedures
    sysprotects
    sysreferences
    sysroles
    syssegments
    sysstatistics
    systabstats
    systhresholds
    systypes
    sysusermessages
    sysusers


    -----------------------------
    I amn't sure . Do you want it or not.

  4. #4
    Join Date
    Aug 2012
    Posts
    1
    What you want can't be done with a single command, only two:


    Code:
    select row_number=identity(10), Folders_Id into #test from tablename
    select * from #test where row_number between 5 and 50
    Last edited by afmf; 08-02-12 at 12:00.

Posting Permissions

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