March 8, 2007 at 12:18 pm
Hello,Does anyone have an example as to how I could take the entire contents of one text file, and append those contents to the content of another text file?
Is there some way to use the WriteLine method (VBScript FileSystemObject) to do this? Thank you for your help!CSDunn
March 8, 2007 at 12:34 pm
set fso=createobject("scripting.filesystemobject")
set nfl = fso.createtextfile("c:\pathtoresultfile\resultfile.txt")
set fl= fso.OpenTextFile("c:\pathtofile1\file1.txt")
do while not fl.atendofstream
nfl.writeline fl.readline
loop
set fl= fso.OpenTextFile("c:\pathtofile1\file2.txt")
do while not fl.atendofstream
nfl.writeline fl.readline
loop
set fl= fso.OpenTextFile("c:\pathtofile1\file3.txt")
do while not fl.atendofstream
nfl.writeline fl.readline
loop
nfl.close
set nfl=nothing
March 8, 2007 at 2:49 pm
Thanks for your help, I'll try this!
CSDunn
March 9, 2007 at 4:00 am
It could also be done using xp_cmdshell and the TYPE command, thus:
EXEC master.dbo.xp_cmdShell 'TYPE C:\TextFile.txt >> C:\TextFile2.txt'
This would append the contents of Textfile.txt to TextFile2.txt on the SQL server. You can also use computer name (\\COMPUTER\...) paths for files over the network using this method.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply