running a branch in DTS if a text file is not empty

  • Hello,

    Does someone know how to execute a braunch in "data transformation service" only if a text file, wich is used to fill a table, is not empty ?

    I also would like to have a mail send to me if the text file is empty.

    Please help it drive me crazy

  • I will do it as a VBscript The type of the Task is ActiveX Script Task.

    Create FileSystemObject File object and check its size. Or if you think that the first line will contain a header, then actually open the file and do 2 ReadLines checking if the second one is empty. Then based on the output use the script that sends an email or use your regular SendMail SP or SMTP XP whatever is applicable in your case.

    Yelena

    Regards,Yelena Varsha

  • You could implement a logic similiar to the looping logic for DTS using the DTSStepExecStatus constants and some script code that checks if the text file is not empty and applies DTSStepExecStat_Waiting to the step's ExecutionStatus property respectively DTSStepExecStat_Inactive if the text file is empty (I normally do this with variables and a dynamic properties task for the sake of laziness).

  • thank's,

    does someone have a snipped of code ? i am newbe in vb script. or maybe know where i can find a good tutorial that explains how to use vb script in active x for DTS ?

  • Hey Guys

    Where can i find the File object

    This is not there in the menu 

    or If i have script, how should i reference the text file here

    Thnx

     

     


    Kindest Regards,

    incubus Online

  • Not sure what you mean.

    The code looks like

    Dim fso, f1

    Set fso = CreateObject("Scripting.FileSystemObject")

    Set f1 = fso.GetFile("c:\test.txt")

    Determining if the file is empty might work by checking the size (f1.size = 0). If you have a text file and you want to check if you have no rows check out the OpenTextFile method of the FSO.

    For more information check out http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/scriptinga.asp. The object you would need is the FileSystemObject.

    Rgs.

  • Hey Rapli

    Thnx a bunch

    This Does solve my problem

    I was breaking my head w/ filesystemobject

    but could not figure out wht i was doing wrong

    Ur code worked like a charm !!!

    Thnx


    Kindest Regards,

    incubus Online

Viewing 7 posts - 1 through 6 (of 6 total)

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