This site is hosted and sponsored by hyve.com specialists in Cloud Hosting UK and VMware Hosting. If you are interested in our services please call us for chat on 0800 612 2524
How to Delete Files In SQL Server#
You can do this using the extended stored procedure. Problem is you need to configure the database to allow this to run. You need to use sql server "service area" configuration. You also need sys admin rights to run this.EXEC master..xp_cmdshell 'del C:\file.txt'
To delete files without requiring this access, use the built-in SQL Server Automation and the FileSystemObject, this also needs to be configured in the database to allow this to run. You need to use sql server "service area" configuration
DECLARE @hr int DECLARE @fileSystem int EXEC @hr = sp_OACreate 'Scripting.FileSystemObject', @fileSystem OUT EXEC @hr = sp_OAMethod @fileSystem, 'DeleteFile', NULL, 'C:\pathtofile.txt' EXEC @hr = sp_OADestroy @fileSystem
Back to SQL Server
Add new attachment
Only authorized users are allowed to upload new attachments.
«
This page (revision-1) was last changed on 06-Feb-2008 15:08 by UnknownAuthor