I have a SQL Server table with a list of file paths for fi开发者_高级运维les that I need to delete from my windows system, is there any way I can accomplish this using batch file in command prompt or any software to help me do this?? appreciate any help.
You could write a select statement that will create the commands for you, then run it from the command line:
e.g.
SELECT 'del /Q ' + file_name FROM your_table;
Save the output results to a file, then you can run it from the command line.
And you may automate the whole thing a little bit more by doing it on the command line with sqlcmd:
sqlcmd -d MyDb -Q "SELECT * FROM (SELECT 'DELETE /Q ' + file_name AS x FROM your_table UNION ALL SELECT 'EXIT') AS x" -h -1 -o temp.bat
temp.bat
DEL temp.bat
精彩评论