Do stored procedures have the ability to delete a file from the OS?
3 answers
try it
Option 1 delete the file using xp_cmdshell
xp_cmdshell 'del y:\file.dat'
Option 2 delete the file using OLE Automation
DECLARE @ResultOP int
DECLARE @OLE_Obj int
EXEC @ResultOP = sp_OACreate 'Scripting.FileSystemObject', @OLE_Obj OUTPUT
EXEC @ResultOP = sp_OAMethod @OLE_Obj, 'DeleteFile', NULL, 'y:\file.dat'
EXEC @ResultOP = sp_OADestroy @OLE_Obj
+3
source to share