dbTalk Databases Forums  

Differentiate flat files for different tables.

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Differentiate flat files for different tables. in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jesse Fitterer
 
Posts: n/a

Default Differentiate flat files for different tables. - 03-23-2005 , 09:24 AM







I have 4 different flat file struture in on
folder(_001.dat,_002.dat,_003.dat,_004.dat)each going to a seperate
table. Right now the logic below grabs all files. I want to be able to
filter on the file extension and send that to its own particular table.

Function Main()

' Declare FSO Related Variables
Dim sFolder
Dim fso
Dim fsoFolder
Dim fsoFilesCollection
Dim fsoFile
Dim sFileName

'Declare Variables
Dim oPKG
Dim oConnection


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #2  
Old   
Jesse Fitterer
 
Posts: n/a

Default Re: Differentiate flat files for different tables. - 03-23-2005 , 11:52 AM






Here is the full code


Function Main()

' Declare FSO Related Variables
Dim sFolder
Dim fso
Dim fsoFolder
Dim fsoFilesCollection
Dim fsoFile
Dim sFileName

'Declare Variables
Dim oPKG
Dim oConnection

' Get Package Object
Set oPKG = DTSGlobalVariables.Parent
' Get Source Connection Object
Set oConnection = oPKG.Connections("Connection 1")

' Import Folder
sFolder = DTSGlobalVariables("ImportFolder")

Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fso.GetFolder(sFolder)

Dim bFound
bFound = False

For Each fsoFile in fsoFolder.Files
sFileName = sFolder & fsoFile.Name
If oConnection.DataSource = sFileName Then
bFound = True
ElseIf bFound = True Then
oConnection.DataSource = sFileName
' Set Pump Step to waiting
oPKG.Steps("Copy Data from ImportTest to [JTEST].[dbo].[ABW_001]
Step").ExecutionStatus = DTSStepExecStat_Waiting
End if


Exit For
End If
Next

Main = DTSTaskExecResult_Success
End Function

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #3  
Old   
Jesse Fitterer
 
Posts: n/a

Default Re: Differentiate flat files for different tables. - 03-23-2005 , 12:07 PM



Here is the full code


Function Main()

' Declare FSO Related Variables
Dim sFolder
Dim fso
Dim fsoFolder
Dim fsoFilesCollection
Dim fsoFile
Dim sFileName

'Declare Variables
Dim oPKG
Dim oConnection

' Get Package Object
Set oPKG = DTSGlobalVariables.Parent
' Get Source Connection Object
Set oConnection = oPKG.Connections("Connection 1")

' Import Folder
sFolder = DTSGlobalVariables("ImportFolder")

Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fso.GetFolder(sFolder)

Dim bFound
bFound = False

For Each fsoFile in fsoFolder.Files
sFileName = sFolder & fsoFile.Name
If oConnection.DataSource = sFileName Then
bFound = True
ElseIf bFound = True Then
oConnection.DataSource = sFileName
' Set Pump Step to waiting
oPKG.Steps("Copy Data from ImportTest to [JTEST].[dbo].[ABW_001]
Step").ExecutionStatus = DTSStepExecStat_Waiting
End if


Exit For
End If
Next

Main = DTSTaskExecResult_Success
End Function

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.