Retriving data IN SQL SERVER 2000

  • bosekolli

    Newbie

    Points: 3

    my name is BABU i have requirement like this any body can help me?

    i have a table name emp with 10000 records and without identity column i want first 5000 records after i want 5000 to 7000 records later 7000 to 10000 is it possible in sql server?

  • Ian Yates

    SSCoach

    Points: 19738

    Hmmm - you've posted this to the wrong forum.

    In any case, what do you mean by you "want" the records?

    Do you want the first 5000 records to have some flag set, then the next 2000, etc? Or do you want to be able to return them in a query?

    In either case, how do you define "first"? You'll need to work out how you want to order the data. This could be by date, name, colour, size, etc, etc depending on what attributes you have for your data. Now that I look again you have employees (the "emp" name is usually for this?) so I suppose name, hire date, salary, etc could be reasonable criteria.

    Are you actually running SQL 2000 or did you just post this question in a forum with 2000 in the name? There are easier ways to do this in 2005...

  • Jeff Moden

    SSC Guru

    Points: 997113

    bosekolli (2/23/2008)


    my name is BABU i have requirement like this any body can help me?

    i have a table name emp with 10000 records and without identity column i want first 5000 records after i want 5000 to 7000 records later 7000 to 10000 is it possible in sql server?

    The answer to both questions is "Yes". Like Ian stated, though, we need just a wee bit more info... Are you in fact using SQL Server 2000 or 2005? Can you post the CREATE statement for the EMP table? In the absense of an IDENTITY column, what is the Primary Key of the table? And, last but not least, what order to you want the results to be sorted by?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".
    "Dear Lord... I'm a DBA so please give me patience because, if you give me strength, I'm going to need bail money too!"

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply