Create a table that contains one one, two twos, three threes etc. upto a given maximum using t-SQl
DECLARE @max int
declare @val int
declare @inner int
set @val = 0
SET @max = 20
WHILE @val<=@max BEGIN
set @inner=0
WHILE @inner<@val BEGIN
insert into @id(number) values (@val)
set @inner= @inner+1
END
set @val = @val +1
END
select * from @id
select count(*) from @id