Don''t delete/load if the file 0 byte -DTS

  • SQL Server 2000 SP4

    I have a DTS package that loads text files from a directory into the database tables. It first deletes the content of the tables, then loads them from the text files. There is a posibility that one or more files can be 0 byte (Up to 4 files).

    I need to setup a DTS package where I need to know if the flat file is 0 byte. If it is 0 byte (Empty file), then I don't want the corresponding table to be deleted. If the file is > 0 byte, then I want the table to be deleted and loaded.

    How can I setup this in the DTS package ?. Is there a script/code can someone share ?

     

    Thanks.

  • Check the size of the files first either using xp_cmdshell 'dir \\server\folder\*.txt'.  You can put these results into a table and query that to determine the size.  You could also use FSO (FileSystemObject) in an ActiveX script.

    Having got the sizes, you will need to disable the step for any file where the size is 0 - you can do this from within ActiveX.

    Have a look at http://www.sqldts.com/246.aspx for the general idea of disabling steps.

     

    J

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply