仅当某些字段发生更改时,SQL Server设置日期 [英] SQL Server set date only when a certain field changes

查看:111
本文介绍了仅当某些字段发生更改时,SQL Server设置日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我想知道以下问题是否有解决方案:我有一个表,并且要向其中添加一个自定义datetime字段,该字段仅在表单中的某个字段发生更改时才设置日期.假设我们有一列存储项目的阶段,并且我希望自定义日期时间字段仅在更改状态字段时才更新,而不在表单上进行任何其他更改时才更新.因此,假设名称字段发生更改,则自定义日期时间保持不变.

预先感谢您的回答.

Hello,

I want to know if the following issues has a solution: I have a table and I want to add to it a custom datetime field which sets the date only when a certain field from a form is changed. Let''s say we have a column that stores the phase of the project and I want the custom datetime field to update only when I change the status field, not any other change on the form. So when, let''s say, the name field is changed, the custom datetime remains unchanged.

Thanks in advance for your answers.

推荐答案

您可以使用触发器.查看下面的文章和MSDn文档.

http://benreichelt.net/blog/2005/12 /13/making-a-trigger-fire-on-column-change/ [ http://msdn.microsoft.com/en-us/library/ms186329.aspx [ ^ ]
You can use triggers. Look at the article below and the MSDn documentation.

http://benreichelt.net/blog/2005/12/13/making-a-trigger-fire-on-column-change/[^]

http://msdn.microsoft.com/en-us/library/ms186329.aspx[^]


这篇关于仅当某些字段发生更改时,SQL Server设置日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆