Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Clages1
Yak Posting Veteran
69 Posts |
Posted - 2013-04-29 : 19:09:20
|
Hi, its me againI found this samples here, but this sample APPEND the Text in the FileI would like to delete the file first..in other words not to append.i did not find the Option in "sp_OAMethod" .something like sp_OAMethod @FS, 'DELETETextFile'TKScarlos lagesDecALTER PROCEDURE [dbo].[sp_AppendToFile] (@FileName varchar(255), @Text1 varchar(max)) AS DECLARE @FS int, @OLEResult int, @FileID intEXECUTE @OLEResult = sp_OACreate 'Scripting.FileSystemObject', @FS OUTIF @OLEResult <> 0 PRINT 'Scripting.FileSystemObject'--Open a fileexecute @OLEResult = sp_OAMethod @FS, 'OpenTextFile', @FileID OUT, @FileName, 8, 1IF @OLEResult <> 0 PRINT 'OpenTextFile'--Write Text1execute @OLEResult = sp_OAMethod @FileID, 'WriteLine', Null, @Text1IF @OLEResult <> 0 PRINT 'WriteLine'EXECUTE @OLEResult = sp_OADestroy @FileIDEXECUTE @OLEResult = sp_OADestroy @FS |
|
|
|
|
|
|