auto incremental field

  • I know sql server can set a field to be auto incremental by a variable (1,2,3,4...) or (1,3,5...)

    But what i need to do is auto increment of 1 group by another field.

    Eg. I have 2 fields in 1 table: that call the field JobNo and SeqNo. For all record under same job, i want the seqNo field to be incremental within that job no. This mean i want a different set of seqno for different job.

    Can i do this in SQL server incrmental field?

     

  • You'll have to implement this with a trigger and manually count the next value for the update. Or you could also use a datetime field which would you allow to resort by group easyly. Is it a possibility?

  • Remember that such a trigger probably needs to deal with the insertion of multiple rows - a tasty bit of coding that might require a cursor.  Recommend that you stay away from this and use an alternative method if poss.


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

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