Results 1 to 4 of 4

Thread: Reading text file in a SP

  1. #1
    Jens Nilsson Guest

    Reading text file in a SP

    Hello!

    Dose anyone know how I can read a text file. I need that info to have in the subject when I use the xp_sendmail.

    Grettings!
    /Jens
    Databas Administrator
    Malmoe - Sweden

  2. #2
    ratatouil Guest

    Reading text file in a SP (reply)

    SET fso = CreateObject("Scripting.FileSystemObject&#34
    Do while not ptr_file.AtEndOfStream
    my_line = ptr_file.ReadLine
    Loop
    ptr_file.close
    SET fso = Nothing

    You can do what you want on the my_line variable or use the ReadAll methods instead of ReadLine.
    I hope i help you


    ------------
    Jens Nilsson at 11/16/00 7:24:31 AM

    Hello!

    Dose anyone know how I can read a text file. I need that info to have in the subject when I use the xp_sendmail.

    Grettings!
    /Jens
    Databas Administrator
    Malmoe - Sweden

  3. #3
    LILLY Guest

    Reading text file in a SP (reply)

    I TRIED THIS CODE AND DID NOT WORK PLS DESCRIBE IN DETAIL PLEASE.

    1. WHETHER THIS COULD BE USED IN TSQL OR NOT


    ------------
    ratatouil at 11/16/00 8:58:20 AM

    SET fso = CreateObject("Scripting.FileSystemObject&#34
    Do while not ptr_file.AtEndOfStream
    my_line = ptr_file.ReadLine
    Loop
    ptr_file.close
    SET fso = Nothing

    You can do what you want on the my_line variable or use the ReadAll methods instead of ReadLine.
    I hope i help you


    ------------
    Jens Nilsson at 11/16/00 7:24:31 AM

    Hello!

    Dose anyone know how I can read a text file. I need that info to have in the subject when I use the xp_sendmail.

    Grettings!
    /Jens
    Databas Administrator
    Malmoe - Sweden

  4. #4
    ratatouil Guest

    Reading text file in a SP (reply)

    Ok so it's not the complete code but only short example.
    So the SET fso = CreateObject("Scripting.FileSystemObject&#34
    is needed.It's the main object : it contain the open,close,delete methods
    Then comes the Set ts = fso.OpenTextFile("c: estfile.txt", 1)
    I forgot this line I'm sorry about this
    So this line is to set the cursor on the open file.The 1 is the ForReading option.The comes the loop :
    Do while not ptr_file.AtEndOfStream
    my_line = ptr_file.ReadLine
    Loop
    It means that it will loop until the end of file.In each loop it store the line read in the my_line variable.
    One last thing : my_line , fso , ts are variable and must be declared.
    Oh yes i forget : This is not Tsql but Vbscript so you write this code in a DTS.




    ------------
    LILLY at 11/17/00 1:17:22 AM

    I TRIED THIS CODE AND DID NOT WORK PLS DESCRIBE IN DETAIL PLEASE.

    1. WHETHER THIS COULD BE USED IN TSQL OR NOT


    ------------
    ratatouil at 11/16/00 8:58:20 AM

    SET fso = CreateObject("Scripting.FileSystemObject&#34
    Do while not ptr_file.AtEndOfStream
    my_line = ptr_file.ReadLine
    Loop
    ptr_file.close
    SET fso = Nothing

    You can do what you want on the my_line variable or use the ReadAll methods instead of ReadLine.
    I hope i help you


    ------------
    Jens Nilsson at 11/16/00 7:24:31 AM

    Hello!

    Dose anyone know how I can read a text file. I need that info to have in the subject when I use the xp_sendmail.

    Grettings!
    /Jens
    Databas Administrator
    Malmoe - Sweden

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •