I have HTML text in a field. I need to get it into a file on my server.
I am using the attached SQL code in a SPROC and need help getting it running. By now I have completely screwed it up, so please set me straight. At present I am getting an error -2146828212 on the 'OpenTextFile' and an error -2147211483 on the WriteLine
@AttachmentHTMLContent has already been correctly loaded with the data I want to write
on has the full path to the filename I want to use (e.g. "D:\Folder1\Folder2\Folder
EXECUTE @OLEResult = sp_OACreate 'Scripting.FileSystemObject', @FS OUT
IF @OLEResult <> 0 PRINT 'Scripting.FileSystemObject got an error'
--Open a file
execute @OLEResult = sp_OAMethod @FS, 'OpenTextFile', @FileID OUT, @EmailAttachmentFileLocation, 8, 1
IF @OLEResult <> 0 PRINT 'OpenTextFile got an error'
execute @OLEResult = sp_OAMethod @FileID, 'WriteLine', Null, @AttachmentHTMLContent
IF @OLEResult <> 0 PRINT 'WriteLine got an error'
EXECUTE @OLEResult = sp_OADestroy @FileID
EXECUTE @OLEResult = sp_OADestroy @FS