Deleting files with sql server

  • I am storing the names of files which have been uploaded to my server in a column called uploaded. All of these files are in the same directory on the server.

    I need to have the actual files deleted when the corresponding record is deleted from the database. Is this possible with a DELETE Trigger? I am very new to T-SQL so any code would be helpful.

    Thanks

  • It is possible. You could use xp_cmdshell to issue a a 'delete filename'.

    Andy

  • Be sure to check security. The account under which SQL Server runs needs to have rights to delete these files from the OS.

    Steve Jones

    steve@dkranch.net

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply