可以将其作为 SQL Server 作业吗?
我有一个文件夹,其中包含用于使用徽章的图像。我有另一个文件夹,其中包含图像的重命名版本(该文件夹位于另一台计算机上)。
我需要创建一个过程来复制和重命名找到的任何新图像。名称之间的映射位于 SQL Server DB 中。
将其创建为 SQL Server 作业并使用 xp_cmdshell 复制文件是一个坏主意吗?这是我的第一直觉,但我以前从未这样做过,所以我很好奇是否有任何我应该知道的问题......
I have a folder that contains images for use badges. I have another folder that contains renamed versions of the images (this folder is on another machine).
I need to create a process that will copy and rename any new images found. The mapping between the names is in a SQL Server DB.
Would it be a bad idea to create this as a SQL Server job and use xp_cmdshell to copy the files? This was my first instinct, but I haven't done this before so I was curious if there were any gottchas i should know about...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
考虑到关于 SO 的大多数简单问题都可以在几秒钟内得到回答,并且您
53 分钟前(在我写这篇文章的时候)问过这个问题,但没有答案表明没有人做过这件事,或者没有人有任何强烈的感觉。
根据我自己的经验,我有时会考虑这一点,但总是选择反对它。原因总是相同的,随着时间的推移,相关操作变得更加复杂,并且在应用程序代码中可以更好地处理。因此,事实证明,在应用程序代码中处理它并且将结果存储在数据库中更容易。
几年前,由于这种模式,我不再考虑这个问题,并将这个选项从常规实践清单中划掉。
编辑:还有一件事(还记得我说过我再也不会考虑它了吗?),我在回答你的另一个问题时记得这一点。这是因为 shell 是使用服务器的权限执行的。您经常必须授予服务器通常没有的权限,这是不好的做法。
Considering most simple questions on SO are answered in seconds, and you
asked this one 53 minutes ago (at the time I'm writing this) and have no answers suggests nobody has done it, or nobody has any strong feelings one way or the other.
In my own experience I have sometimes found myself considering this, and always chosen against it. The reason always turns out the same, the operation in question becomes more complicated over time, and is better handled in application code. So it turns out to be easier to handle it in app code, and to just store the result in the database.
Some years ago I stopped thinking about it and crossed this option off the list of regular practice, owing to that pattern.
EDIT: One more thing (Remember I said I never think about it anymore?), which I remembered in answering your other question. It's because the shell is executing with the server's permissions. You often have to give the server privileges it would not normally have, which is bad practice.