This simple script from Ramunas Balukonis is useful when you need to log in to a file from SQL server. The script opens a file and adds user-specified information to that file.
Usage: dbo.append_log (@file_name VARCHAR(255) /* file2appaned*/, @msg VARCHAR(8000) /* msg2log */)
You need to set permission on master..OACreate, master..OADestroy, master..GetErrorInfo, master..sp_OAMethod xps to user, wich will execute this sp. Also you need to set write permissions on file @file_name, to the account under which SQL Server is running. Also, the “Scripting.FileSystemObject” object should be installed on the server.