I need a way to number records reptitively throughout a table

  • The software that my client is using needs to have 20 rows of data per person in order to properly format the form. There is nothing I can do to the software. What I need is a way (I can do it with the cursor, but don't want to) that I can see how many records each person has and number them 1 through 5, 1 through 8 etc. I have a field created that will accept these numbers. I mainly want to find a non-cursor way to do it.

  • Use the new ROW_NUMBER() feature in 2005.

    select *,

    Row_number() over (PARTITION BY PersonID)

    From

    tblPerson

    Partition by works like a group by (it's what resets the count)

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Thank you! That worked beautifully.

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

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