Assign Unique ID within groups of records

I have a situation where I need to add an arbitrary unique id to each of a group of records. It's easier to visualize this below. Edited 11:26 est: Currently the lineNum field has garbage. This is running on sql server 2000. The sample that follows is what the results should look like but the actual values aren't important, the numbers could anything as long as the two combined fields can be used for a unique key.

OrderID lineNum AAA 1 AAA 2 AAA 3 BBB 1 CCC 1 CCC 2 

The value of line num is not important, but the field is only 4 characters. This needs to by done in a sql server stored procedure. I have no problem doing it programatically.

16.8k 4 4 gold badges 33 33 silver badges 39 39 bronze badges asked Feb 13, 2009 at 15:44 1,292 3 3 gold badges 16 16 silver badges 19 19 bronze badges

The table which you posted is what you want or what you have? Please post both: what you have now and what you want to get. As for now, it's confusing.