Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query on identity columns

Author  Topic 

daniel.newman@bis-web.net
Yak Posting Veteran

71 Posts

Posted - 2001-08-09 : 10:28:21
Hello all,

I have the following table structure

#TaskID bigint X
#PlanNo varchar(10) X
Status char(1) X
TaskDesc varchar(255) X
TaskInfo varchar(4000)
RTO int X

The hashs indicate primary keys, and the X's are for not null columns.

I thought that by having the primary key assigned to two columns, the identity would work differently. What I would like, is for every PlanNo to keep an incremental count, but whenever a new PlanNo is inserted, then the identity is set to 1 for that PlanNo.

I could do this by having another table handling the numbers, but wondered if there was an easier way of doing it?

So I could have the following PK's:

1 BCB018
2 BCB018
3 BCB018
1 RFX005
2 RFX005
3 RFX005

And the next Insert of a Task for BCB018 would have a TaskID of 4. Is this possible?

Daniel Newman.

   

- Advertisement -