Results 1 to 4 of 4

Thread: Insert Text at beginning of file with vbscript

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Sydney Australia
    Posts
    476

    Insert Text at beginning of file with vbscript

    Hi Team

    I need to insert a line of test at the beginning of a csv file using an ActiveX Script Task in SQL 2000. Does anyone know of an elegant way to do this?

    Thanks FW

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Insert Text at beginning of file with vbscript

    Open an output file. Write the line to be inserted. Open the existing file. Read it and write it to the output file. Close both files. Kill the input file. Rename the output file to the original name.

    You can't insert into an existing file.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Sydney Australia
    Posts
    476

    Re: Insert Text at beginning of file with vbscript

    Thanks AL, I was hoping there was a way without copying the whole contents. But never mind, looks like this is the way.

    RW

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Insert Text at beginning of file with vbscript

    another way you can do it, though it may not be popular here, is to write the additional information to a new file then shell to dos and use copy to combine the 2 files


    To append files, specify a single file for destination, but multiple files
    for source (using wildcards or file1+file2+file3 format).
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width