So I came up with this:
declare @months table (month int)
insert into @months
values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12)
declare @days table (day int)
insert into @days
values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10),
(11), (12), (13), (14), (15), (16), (17), (18), (19), (20),
(21), (22), (23), (24), (25), (26), (27), (28), (29), (30), (31)
select * from @months m
cross join @days d
order by month, day
The hint here its to use cross join, that allows you to create a desired multiplicity.
Although simple, solved my problem for that moment. And after thinking a little, came up with a better solution.
So don't miss the next post, and check a better way to create a very useful numeric table.
See you next time!
No comments:
Post a Comment