How to delete files on the directory via MS SQL Server -
i trying delete file directory inside windows using following query,
exec xp_cmdshell 'del "c:\root\sfd_devtracker\'+@deletefile + '"';
when execute command gives following error,
incorrect syntax near '+'.
in @deletefile
variable have filename have delete. have done wrong here?
xp_cmdshell requires literal string passed parameter. cannot construct value on fly.
try this:
declare @cmd nvarchar(max) = 'xp_cmdshell ''del "c:\root\sfd_devtracker\' + @deletefile + '"'''; exec (@cmd)
Comments
Post a Comment