February 24, 2016 at 10:36 pm
I'm a newbie and trying to understand what does this code do. The only information I have about this code is that it used to calculate values from year 2015 to 2001. I don't understand how this code works. Is there anyone can help me with interpreting the code?
SET @MYYEAR = @FIRST_YEAR
SET @QUERY = "UPDATE BACKWARD_PASS SET "
WHILE (@MYYEAR <= @LAST_YEAR - 1)
BEGIN
IF (@MYYEAR <> @LAST_YEAR - 1)
BEGIN
SET @QUERY = @QUERY +
"Calculate_Backward." + '[' + cast(right(@MYYEAR,2) as VARCHAR(10)) + ']' +
" = cast(nullif(" + '[' + cast(@MYYEAR as VARCHAR(10)) + ']' + ",0) as float(1))/cast(nullif(" +
'[' + cast(@MYYEAR+1 as VARCHAR(10)) + ']' + ",0) as float(1)),
"
February 24, 2016 at 10:54 pm
Well this code is making a Dynamic Query based upon the parameter(s) value and if you want to check whats is making in the end. In the end of the code place the following :
SELECT @QUERY
this will give you the complete query copy the text and paste it in a t-sql and you will understand what its actually doing.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy