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 |
jaybee
Yak Posting Veteran
72 Posts |
Posted - 2007-11-20 : 20:18:02
|
Hi all, Background - I've got an academic package the following script is part of that uses lookups to extract row-based sales data from Access, maps columns using values from the first row of an Excel spreadsheet (source), sales targetsI've highlighted in bold the areas I'm struggling to follow (as a pure Admin guy!),Function Main() Dim i DTSDestination("Product") = DTSSource("Product") 'Load Actual sales data for each month For i = 1to DTSGlobalVariables("ActualsThroughMonth").Value DTSDestination(i+1) = DTSLookups("GetActualsCurrentMonth").Execute(DTSSource("Product"),i, DTSGlobalVariables("CurrentYear").Value) Next DTSDestination("Full Year") = DTSLookups("GetActualsYTD").Execute(DTSSource("Product"), DTSGlobalVariables("ActualsThroughMonth").Value),DTSGlobalVariables("CurrentYear").Value) Main = DTSTransformStat_OKEnd FunctionI'm not sure what the "For i = 1" is about, seems like some programming procedure I'm not aware of.Execute(DTSSource("Product"), don't know why this is a source, and is the word 'product' in speech marks because there are numerous products?Let me know if more info needed. I'll be glad to get this one cleared up, it's bugged me a long time now.Thanks,Jaybee. |
|
snake9284
Starting Member
10 Posts |
Posted - 2007-11-21 : 14:45:13
|
I'm fairly new to SQL (~2 months) but I'll give it a shot. The quote: For i = 1to DTSGlobalVariables("ActualsThroughMonth").ValueDTSDestination(i+1) = DTSLookups("GetActualsCurrentMonth").Execute(DTSSource("Product"),i, DTSGlobalVariables("CurrentYear").Value)Next
is a loop that goes from 1 through DTSGlobalVariables("ActualsThroughMonth").Value which you can see if you open the DTS package and right click and open the package properties option. You can select the global variables tab to see what variables the package is using. My guess is that this is just the number of days for the month that you are loading so for january you would would loop from 1 to 31. You said that the info in in an Excel file so to me it looks like the Execute(DTSSource("Product"), is part of a vlookup function that the package is performing on the spreadshhet.That's my .02 at least ;-) |
|
|
|
|
|
|
|