Checking for a file''s footer

  • Hi there,

    I have a DTS Package that picks up a number of text files and loads them into a database.(so far so good)

    However, I want to perform some basic validation on the file before I decide to load it. All I really need to check for is whether the file has a header and a footer.

    I can check the header by using a TextStream.Read(3) as I know the first 3 characters of the file will be 'HDR'. But how do I check to see if the file has a footer?

    I thought I could use textStream.SkipLine to go to the last line of the file... but how do I know how many lines I have to skip?

    I'd appreciate any help.

    Regards

    David

     

     

     

     

     

  • In a Do ..Loop read until AtEndOfStream  In the loop store each line into a variable. After the loop ends, read the the last line to check for Footer details.

  • SqlJunkie beat me to the punch

    As an alternative why not load the data into a staging table (with rowid IDENTITY column) then you can check the data by reference rowid=1 and rowid=MAX(rowid)

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Went with the AtEndOfStream solution at the end and it works fine.

    Thank's guy's... much appreciated.

Viewing 4 posts - 1 through 3 (of 3 total)

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