Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002
    Posts
    1

    Question Unanswered: Updating Tables Sequentially

    Im going to update a table with 300,000 records in Microsoft SQL Server 2000. I have a field named mark, and all the records in this field are NULL. What i want to do is update the field mark sequentially, for example:

    This is the table with NULL values in the mark field.

    RecordID mark
    1
    2
    3
    4
    5
    6
    7
    8
    9

    The result should be like this:

    RecordID mark
    1 1
    2 2
    3 3
    4 1
    5 2
    6 3
    7 1
    8 2
    9 3

    Can somebody help me with this. I will appreciate any help you could give me.

  2. #2
    Join Date
    May 2002
    Posts
    18

    Re: Updating Tables Sequentially

    Try this solution

    declare @index int
    set @index = 0
    update Record set mark= @index, @index= @index+1



    Originally posted by romvoid
    Im going to update a table with 300,000 records in Microsoft SQL Server 2000. I have a field named mark, and all the records in this field are NULL. What i want to do is update the field mark sequentially, for example:

    This is the table with NULL values in the mark field.

    RecordID mark
    1
    2
    3
    4
    5
    6
    7
    8
    9

    The result should be like this:

    RecordID mark
    1 1
    2 2
    3 3
    4 1
    5 2
    6 3
    7 1
    8 2
    9 3

    Can somebody help me with this. I will appreciate any help you could give me.

Posting Permissions

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