Skip to main content

Currently sequences are not allowed to be configured as default constraint on a table column. However this would make dev life easier if we could do an insert on a table without having to fetch the next sequence value explicitly. It would work similarly to an identity seed, however you could use the sequence on multiple tables to have a shared unique value, this is a powerful concept.

Currently you can build a work-around with tags and dynamic code, but it would be better if it were integrated into de software factory so that it is visibile in the right place and avoids complexity and confusion for new developers.

Hi ​@benjaminwestra,

Just to confirm, this is the intended result?

-- Create a sequence
create sequence dbo.MySequence
as int
start with 1
increment by 1;

-- Create a table with a default value from the sequence
create table dbo.MyTable
(
id int default (next value for dbo.MySequence),
name nvarchar(100) not null
);

We currently indeed do not support a default value query that looks like that. Perhaps we should even consider a mapping between column and sequence in this case as Default value.


NewOpen

@Mark Jongeling you are correct, you example shows the intended result.