Skip to main content
Open

Allow default constraint for sequence

Related products:Software Factory
  • September 26, 2025
  • 3 replies
  • 56 views

Forum|alt.badge.img

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.

3 replies

Mark Jongeling
Administrator
Forum|alt.badge.img+23
  • Administrator
  • September 26, 2025

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.


Jeroen van den Belt
Administrator
Forum|alt.badge.img+10
NewOpen

Forum|alt.badge.img

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