Deleting files from file system using T-SQL

  • Hello,

    I have a file located in c:\test.jpg that I want to do delete using T-SQL, how can I do this? (need to use this later in a DELETE trigger to remove image files)

  • Use xp_cmdshell

    As an example:

    EXEC xp_cmdshell 'del C:\test.jpg'

    Check BOL for any restrictions on using this sp.

  • Could possibly also use xp_delete_file

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

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