need help!!

Last Post 28 Oct 2012 04:41 PM by gunneyk. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Liridon
New Member
New Member

--
26 Oct 2012 07:22 AM
If somebody could help me to solve this problem
I am trying to insert same data from the previews month except Month should be Month+1. And I did it in this way (code down), works perfect. What I want now is when Month > 12 then Month = 1, this mean to start again from the first month (January).
Here is my table with fields..

INSERT INTO myTable ( [Year], field1, field2, field3, field4, Month )
SELECT [@CurrentYear] AS [Year], field1, field2, field3, field4, Month+1
FROM myTable
WHERE [Year]=[@PreviousYear];
Thanks.
LirUKA
gunneyk
New Member
New Member

--
28 Oct 2012 04:40 PM
Use a CASE expression. I assume Month is an INTEGER so it owuld look something like this:

Instead of Month + 1
use
CASE WHEN Month = 12 THEN 1 ELSE Month + 1 END
gunneyk
New Member
New Member

--
28 Oct 2012 04:41 PM
Use a CASE expression. I assume Month is an INTEGER so it owuld look something like this:

Instead of Month + 1
use
CASE WHEN Month = 12 THEN 1 ELSE Month + 1 END
You are not authorized to post a reply.

Acceptable Use Policy