sql statement while loops that displays increment month

Hi everyone,

Can anyone show me on how to create a while loop that shows a increment of months?
apmanzojr1Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Anthony PerkinsConnect With a Mentor Commented:
Can anyone show me on how to create a while loop
Why does it have to be a while loop?

that shows a increment of months?
Can you tell us what output to expect?
0
 
CboudrozCommented:
DECLARE @i INT
DECLARE @iNumberOfLoop INT
DECLARE @dtOrderDate DATETIME

SET @iNumberOfLoop = 12
SET @dtOrderDate = GETDATE()

SET @i = 1

WHILE @I >=iNumberOfLoop 
BEGIN


SET @dtOrderDate = DATEADD(m, @i, @dtOrderDate)

PRINT @dtOrderDAte

SET @i = @i+1

END

Open in new window

0
 
jogosConnect With a Mentor Commented:
@Cboudroz
If you increment in the loop, please take other result-variable for the output
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.