Writing to a text file from SQL Server with out using Command shell
I am trying to write a log file when ever a script is run. the Log file is .txt file. I am using the following codeto do that - create PROCEDURE [dbo].[WriteToFile] @File VARCHAR(2000), @Text VARCHAR(2000) AS BEGIN DECLARE @OLE INT DECLARE @FileID INT EXECUTE sp_OACreate 'Scripting.FileSystemObject', @OLE OUT EXECUTE sp_OAMethod @OLE, 'OpenTextFile', @FileID OUT, @File, 8, 1 EXECUTE sp_OAMethod @FileID, 'WriteLine', Null, @Text EXECUTE sp_OADestroy @FileID EXECUTE sp_OADestroy @OLE END I have already activated the permissions for them to work but they are not working. Figured out that the " EX
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.