How to erase text file using SQL server | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

How to erase text file using SQL server

Hi everyone, I try to find a way to erase text file data . Not to delete it like this: exec master..xp_cmdshell ‘del c: est.txt’
But instead just emty text file and leave it on the same place. Reason: our vendor populate that file with some values, I use those values for
forming email to users, then I need to erase them and wait for an other values. Any idea will be appriciated.
Could you delete it as above and then create a new blank file? I’m not sure how to create a new file but you could copy a template one using exec master..xp_cmdshell ‘copy c: emplate.txt C: est.txt’. If you must empty it or partly empty it I suggest using the Windows File Scripting object. Either by writing a vbs script or using sp_OACreate ‘Scripting.FileSystemObject’. If there are any VB people in the forum they maybe of more help…. Simon
It is better to use Client application to do this Madhivanan Failing to plan is Planning to fail
True, why not use VB or other client application to accomplish the task and you can call the same from SQL server to reduce the contenttion. Satya SKJ
Contributing Editor & Forums Moderator
http://www.SQL-Server-Performance.Com
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
]]>