By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table t (ArticleId int, groupId char(10));
insert into t (ArticleId) select 1
insert into t (ArticleId) select 2
insert into t (ArticleId) select 3
insert into t (ArticleId) select 4
4 rows affected
select * from t;
ArticleId | groupId |
---|---|
1 | null |
2 | null |
3 | null |
4 | null |
with g as (select * from(values('A'),('B'),('C'),('D'))v(GroupId))
insert into t
select t.ArticleId, g.GroupId
from t
cross join g;
16 rows affected
select * from t
order by articleId, groupid;
ArticleId | groupId |
---|---|
1 | null |
1 | A |
1 | B |
1 | C |
1 | D |
2 | null |
2 | A |
2 | B |
2 | C |
2 | D |
3 | null |
3 | A |
3 | B |
3 | C |
3 | D |
4 | null |
4 | A |
4 | B |
4 | C |
4 | D |