In SQL Server, you can use the system internal stored procedure xp_fileexist to determine whether a file exists, and then use xp_cmdshell to delete the file if it exists. Xp_fileexist In addition to being able to determine whether a file exists, you can also determine whether a folder exists, and here is an example of using these two.
Deleting a file stored procedure
ALTER proc [dbo]. [Delfile_p]
(@path nvarchar (200))
As
DECLARE @result int
exec master.dbo.xp_fileexist @path, @result out--paths can have spaces
If @result = 1--1 exists This file, 0 does not exist
Begin
--If the path has a space, you must replace the space character before executing the Cmdshell, enclose in double quotes
Set @path = ' del ' + replace (@path, ', ' "')
EXEC Master.dbo.xp_cmdshell @path
End
Calling stored procedures exec MIS.dbo.delFile_P ' f:/internet Explorer 6 green version/install.log '