question

rkvvrkvarma avatar image
rkvvrkvarma asked

stored procedure code to implement the following scenario.

I have two tables (Stage. PP_Projects (Source table) ,DBO.PP_Projects (Target table) ) and need to implement the following scenario in a stored procedure. For Populating the FY Columns we need to be using the Period_NUM, Period_Year, DNLD_DATE from the Stage. PP_Projects. 1. FY_Period_Year is the direct mapping from the Period_year column in the stage.PP_Projects 2. FY_Period_NAME is also the Direct Mapping for the from the Period_NAME column in the stage.PP_Projects 3. FY_Period_START_DATE is the Start date of the Period which should be populated based on the DNLD_DATE. 4. FY_Period_END_DATE is the END Date of the period which needs to be calculated based on the next DNLD_DATE, which is the day before the next DNLD_DATE. 5. FY_QUARTER_NUMBER is based on the Period_NUM. IF the Period_NUM is 1 to 3 then 1, if the period_num is 4 to 6 then 2 , if period_num is 7 to 9 the 3 , if period_num greater than 9 then 4. 6. FY_QUARTER is also based on the Period_NUM. IF the Period_NUM is 1 to 3 then Q1, if the period_num is 4 to 6 then Q2 , if period_num is 7 to 9 the Q3 , if period_num greater than 9 then Q4. Can you please help me to solve this
sql-server-2008stored-procedures
2 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Do you have sample data and expected outcomes? Majority of this can be done by a simple update join query with a case for the quarters e.g. UPDATE tar SET tar.col1 = sor.col1 FROM source sor INNER JOIN target tar ON sor.something = tar.something
1 Like 1 ·
Hello Anthony, Thanks fro the reply. Here is the sample data
0 Likes 0 ·

1 Answer

· Write an Answer
rkvvrkvarma avatar image
rkvvrkvarma answered
Hello Anthony.green, here is the sample data : Source Table - ![alt text][1] [1]: /storage/temp/4379-capture123.png

capture123.png (17.7 KiB)
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.