May 21, 2006 at 8:25 pm
I am trying to load a text file into a table with multiple records ending with {CR}{LF} except for the last record which ends with nothing. I used Hex Edit to verify this value is missing.
DTS will load all the records but skip this last record.
Any advice on how to get DTS not to skip this record or add a {CR}{LF} when it is missing?
David Bird
May 23, 2006 at 10:31 am
In an ActiveX Script task, you could open the file as a text stream using the File System Object and read all into a string. You could then open a new file for writing and apply the contents of that string along with a vbCrLf.
Dim objFSO
Dim objSourceFile
Dim objDestinationFile
Const ForReading = 1
Const ForAppending = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSourceFile = objFSO.OpenTextFile("c:\sourcefile.txt", ForReading)
Set objDestinationFile = objFSO.CreateTextFile("c:\destinationfile.txt", ForAppending)
Dim strData
strData = objSourceFile.ReadAll & vbCrLf
objDestinationFile.Write strData
objSourceFile.Close
objDestinationFile.Close
Set objSourceFile = Nothing
Set objDestinationFile = Nothing
Set objFSO = Nothing
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply