December 10, 2003 at 10:57 am
I am importing multiple text files into a single table. I need to create a report that identifies the number of records from each file. How can I do this?
December 10, 2003 at 3:29 pm
if the rows are delimited by CRLF all you have to do is COUNT the number of CRLF in the file and loop through all of them.
This is Fairly easy done with a script
HTH
* Noel
December 10, 2003 at 3:32 pm
Do you need the count before or after you import the data? If you need it after the import you can use an ActiveXScript task to return the RowsComplete value from the Datapump task.
Hope this helps
Phill Carter
--------------------
Colt 45 - the original point and click interface
--------------------
Colt 45 - the original point and click interface
December 11, 2003 at 7:26 am
I am 100% with Phill here you didn't specify if you need the count before or after and I believe for after Phill's a very good choice
* Noel
December 11, 2003 at 9:19 am
Thanks guys
I do need it after the load. I will try your suggestions.
December 11, 2003 at 10:23 am
Here is a little VB Script that will do the job. You can put it into an ActiveX task in your DTS package. It writes the count to a file, but you could do anything you like with it.
quote:
'**********************************************************************' Visual Basic ActiveX Script
'************************************************************************
Function Main()
'Count number of lines in file without loading whole file into memory...
strFileToWrite = "c:\MyCountOutput.txt"
strFileToRead = "\\MyServer\MyShare\MyFileToRead.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fso2 = CreateObject("Scripting.FileSystemObject")
Set tf = fso.OpenTextFile(strFileToRead)
x = 0 'Set counter
'Count the lines...
i = 1: iP = 0
Do While tf.AtEndOfStream <> True
sMain = tf.ReadLine
x = x + 1
Loop
tf.Close
set tf = nothing
set fso = nothing
'Write the count to a text file...
'2 = Open for writing (overwrite old file); TRUE means create the file if does not exist
set tf2 = fso2.OpenTextFile(strFileToWrite, 2, TRUE)
tf2.Write x
tf2.Close
set tf2 = nothing
set fso2 = nothing
Main = DTSTaskExecResult_Success
End Function
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply