![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is there anything wrong with this? Or a better way to do this? Ryan Function Main() Dim objFSO Dim objFile Dim objFolder Dim strFileName Dim strParentFolderName Dim objPKG Set objPKG = DTSGlobalVariables.Parent strFileName = "" strParentFolderName = DTSGlobalVariables("ParentFolderName").Value Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strParentFolderName) For Each objFile In objFolder.Files if objFile.size <> 0 then strFileName = objFile.Name strAbsolutePathName = strParentFolderName & strFileName DTSGlobalVariables("FileName").Value = strFileName Exit For end if Next IF strFileName = "" then objPKG.Steps("DTSStep_DTSDataPumpTask_3").Executio nStatus = DTSStepExecStat_Waiting end if Main = DTSTaskExecResult_Success End Function |
#3
| |||
| |||
|
|
With the code below, you are exiting your for loop when you get the first filename that has data in it. Is this what you want to do, or do you want to loop through all files in the folder and use the data pump task to insert each file that has data. Depends on what you want to do. If you want to loop through each file that has data in the folder, and import them one at a time see this article http://www.sqldts.com/default.aspx?246 -- Simon Worth "Ryan" <Ryan (AT) discussions (DOT) microsoft.com> wrote in message news:25E12962-454B-469C-92BC-99200EEF25E1 (AT) microsoft (DOT) com... Is there anything wrong with this? Or a better way to do this? Ryan Function Main() Dim objFSO Dim objFile Dim objFolder Dim strFileName Dim strParentFolderName Dim objPKG Set objPKG = DTSGlobalVariables.Parent strFileName = "" strParentFolderName = DTSGlobalVariables("ParentFolderName").Value Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strParentFolderName) For Each objFile In objFolder.Files if objFile.size <> 0 then strFileName = objFile.Name strAbsolutePathName = strParentFolderName & strFileName DTSGlobalVariables("FileName").Value = strFileName Exit For end if Next IF strFileName = "" then objPKG.Steps("DTSStep_DTSDataPumpTask_3").Executio nStatus = DTSStepExecStat_Waiting end if Main = DTSTaskExecResult_Success End Function |
#4
| |||
| |||
|
|
I understand looping (jumping backwards), but thanks anyways. I use a similar script to jump back after I move the file out of the unprocessed directory (thereby processing every file in the directory one at a time). What I want to know is if this is the best way to jump forward? Basically, will it skip the interrim steps without generating errors? I want to skip the transformation step and a couple of transformation related steps, if there are no files for the day, but still run the last few steps in one of the logical branches (notifications, reports, etc). "Simon Worth" wrote: With the code below, you are exiting your for loop when you get the first filename that has data in it. Is this what you want to do, or do you want to loop through all files in the folder and use the data pump task to insert each file that has data. Depends on what you want to do. If you want to loop through each file that has data in the folder, and import them one at a time see this article http://www.sqldts.com/default.aspx?246 -- Simon Worth "Ryan" <Ryan (AT) discussions (DOT) microsoft.com> wrote in message news:25E12962-454B-469C-92BC-99200EEF25E1 (AT) microsoft (DOT) com... Is there anything wrong with this? Or a better way to do this? Ryan Function Main() Dim objFSO Dim objFile Dim objFolder Dim strFileName Dim strParentFolderName Dim objPKG Set objPKG = DTSGlobalVariables.Parent strFileName = "" strParentFolderName = DTSGlobalVariables("ParentFolderName").Value Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strParentFolderName) For Each objFile In objFolder.Files if objFile.size <> 0 then strFileName = objFile.Name strAbsolutePathName = strParentFolderName & strFileName DTSGlobalVariables("FileName").Value = strFileName Exit For end if Next IF strFileName = "" then objPKG.Steps("DTSStep_DTSDataPumpTask_3").Executio nStatus = DTSStepExecStat_Waiting end if Main = DTSTaskExecResult_Success End Function |
![]() |
| Thread Tools | |
| Display Modes | |
| |