Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Concatch
Starting Member
4 Posts |
Posted - 2011-05-26 : 02:45:41
|
I have a table called UpdatedFigures with the following headings: ProductType, Month13, Month14, Month15.......Month24. Under each month there are numeric values and under Product type there is a row for ProductAlpha, ProductBeta and ProductGama. Each Row is populated with eh numeric values from the months. I have a separate table called ModelObject with a single column called Script.In the script column I have with_cell_ProductAlpha_TimePeriod.###.SetValue$$$with_cell_ProductBeta_TimePeriod.###.SetValue$$$with_cell_ProductGama_TimePeriod.###.SetValue$$$I need to do a while loop that will will replace the ### with Month13 through to Month 24 and replace the $$$ with the corresponding values for the Months.The scripts for ProductAlpha, ProductBeta and ProductGama will have 12 iterations each.This is the basic concept I will need to apply it on a much larger scale.Thanx in advance!!! |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-26 : 04:39:36
|
Why do you need a loop?Do you want with_cell_ProductBeta_TimePeriod.###.SetValue$$$to change towith_cell_ProductBeta_TimePeriod.Month13.SetValue$$$Not sure what you want the $$$ to change to - is there a single row in your UpdatedFigures and you want the Month13 figure?You will need a lookup table to map the greek letters to numbers - but if you are creating that - which will have 24 entries - you might as well manually update the script itself which I guess will also have 24 entries. That is unless there is some way of mapping the text to the month number already.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
Concatch
Starting Member
4 Posts |
Posted - 2011-05-26 : 05:15:47
|
I need a loop because what I want eventually iswith_cell_ProductAlpha_TimePeriod.Month13.SetValue 2525with_cell_ProductAlpha_TimePeriod.Month14.SetValue 473643with_cell_ProductAlpha_TimePeriod.Month15.SetValue $$$"""with_cell_ProductAlpha_TimePeriod.Month24.SetValue 7347338 with_cell_ProductBeta_TimePeriod.Month13.SetValue$$$with_cell_ProductBeta_TimePeriod.Month14.SetValue$$$with_cell_ProductBeta_TimePeriod.Month15.SetValue$$$"""with_cell_ProductBeta_TimePeriod.Month24.SetValue$$$The $$$ will change to numeric values from the Updated figures table which looks like this:Product Type Month13 / Month14/...Month17/..............Month24ProductAlpha 2525 / 473643 /...some value/............7347338ProductBeta 4534 / 623632 /...some value/...........38628638ProductGama 6583 /834773 /...some value/...........84723236This is a very simplified model. My actual Updated figures table contains over 2000 Product Types. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-26 : 07:17:57
|
Do you need to do an update or can you populate the ModelObject table from UpdatedFigures?The way you describe this it sounds like the data isn't fixed.The only way from your description is to Use thewith_cell_ProductAlpha_TimePeriodto get the row from UpdatedFiguresBut if the script is alwayswith_cell_<xxxxxx>_TimePeriod.<ccccc>.SetValue <$$$>And you want entries for all rows in UpdatedFiguresthen it's probably easier to generate from scratch.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
|
|
|