While Loop in SQL Server

Hi all,

I want to insert data(month&year) from 2014 till now to my SQL Server DB - into temp table using 2 while loop.

drop table #loop
create table #loop
(seq int identity(1,1),
[month] smallint,
[Year] smallint)
Declare @year int=2014
Declare @Month int = 1
Declare @Currentyear int =(select year(getdate()))
Declare @Currentmonth int =(select month(getdate()))

While (@year <= @Currentyear)
Begin
While ((@Month <= @Currentmonth and @year= @Currentyear )) or (@Month <= 12 and @year< @Currentyear )
Begin
insert into #loop([month] ,[year]
values(@Month,@year)

set @Month = @Month +1
End
set @year = @year +1
End

select * from #loop

For some reason I cant not get 2015 data .
Anyone have an idea why ?

Thanks

Hello,


Thank you for the question. Sorry but from you request is not clear which GroupDocs App do you use. Could you please share with which GroupDocs library and which version do you use.

Please not that this forum is only for GroupDocs products.

Thank you.