当我从数据库中删除相应的条目时,我们可以从服务器中删除物理文件吗? [英] Can we delete the physical file from server when I delete the corresponding entry from database?
本文介绍了当我从数据库中删除相应的条目时,我们可以从服务器中删除物理文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我从数据库中删除相应的条目时,我们可以从服务器中删除物理文件吗?
Can we delete the physical file from server when I delete the corresponding entry from database?
即C:\Test\Test.txt->当从数据库中删除此记录,我需要从提到的位置删除相应的Test.txt文件。
有没有办法,我正在使用SQL 2008。
i.e., C:\Test\Test.txt -> when deleting this record from database, i need to delete the corresponding Test.txt file from mentioned location. Is there a way, I m using SQL 2008.
任何帮助都是非常可观的。
Any help would be highly appreciable..
谢谢
推荐答案
方法是:
- 使用
xp_cmdshell
proc(exec master..xp_cmdshell'del C:\Test\Test.txt') - 使用.NET CLR不安全的proc(需要以任何.NET语言编写并部署到sql server。这是一个很长的故事)
- use of
xp_cmdshell
proc (exec master..xp_cmdshell 'del C:\Test\Test.txt') - use the .NET CLR unsafe proc (need to write in any .NET language and deploy to sql server. Its a long story)
两种方式都很丑陋
再一次-这是最糟糕的做法。服务器不应删除用户文件或任何文件,因为它们不是其数据库的组成部分。
And once again - it is the worst practice. Server should not delete user files, or any files, is they are not integral part of its database.
这篇关于当我从数据库中删除相应的条目时,我们可以从服务器中删除物理文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文