Suppose that you have a table with the following structure:
CREATE TABLE [log] (
[type] int NOT NULL,
[stat] nvarchar(20) NOT NULL,
[id] int IDENTITY (1, 1) NOT NULL,
descr nvarchar(20),
PRIMARY KEY ([type], [stat], [id])
)
Is it possible to force the [id]
to be incremented only whenever the other two PK fields have the same values, and not independently as is now? For instance:
type stat id descr
5 ERROR 1 Test <---
3 WARNING 1 Test
5 ERROR 2 Test <---
2 ERROR 1 Test
1 WARNING 1 Test
5 WARNING 1 Test
5 ERROR 3 Test <---