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.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 DTS trying to import a blank txt file

Author  Topic 

slboytoy
Starting Member

30 Posts

Posted - 2005-01-24 : 15:36:59
I have a DTS package that updates a bunch of tables from a txt file. The odd time, there will be no updates, so the txt file will be blank. Making the DTS package fail. Is there a way to check if the file is blank, then just ignor the next step??

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2005-01-24 : 18:38:26
Yeah you could use a script task to read the file and return a fail if it's blank, then use workflow to route around the next step.

Actually, now I think about it, why not just use workflow to route to the next step if the DTS fails ?



Damian
Go to Top of Page

slboytoy
Starting Member

30 Posts

Posted - 2005-01-25 : 11:00:45
That is how I have it now, if it fails, then just move onto the next file. It's not really a big deal, I just wanted to see if there was a 'checkmark' box or something simple like that. Thanks for your help
Go to Top of Page

slboytoy
Starting Member

30 Posts

Posted - 2005-01-31 : 10:45:50
Again Danfran right now that is how I am doing it. (Just like when you helped me out in the subject 'Sums of Sums')
I have an ActiveX to check to see if there is a file to begain with. It gets a 'Success or Fail' status.

Next ActiveX checks to see if there are any records in there. I could read the file size, or read the first line of data. Either way works fine that I've tested. So its all good up to now.

[CODE]Function Main()

Dim strFile 'String of text file
Dim objFile 'Scripting Object
Dim FileInput 'Text File Source

Set objFile = CreateObject("Scripting.FileSystemObject")

strFile = DTSGlobalVariables("strFile").Value

' Open the file
Set FileInput = objFile.OpenTextFile(strFile, 1)

If FileInput.AtEndOfStream Then
Main = DTSTaskExecResult_Failure
Else
Main = DTSTaskExecResult_Success
End If

Set objFile = Nothing
End Function[/CODE]

How can i made the ActiveX quit the DTS with a success status when there is an empty file?

So in an ActiveX file we have..

No file -> Fail
File with Data -> Success
File with no Data -> Success but quit DTS package
Go to Top of Page
   

- Advertisement -