Datetime的默认约束 [英] Default constraint for Datetime

查看:256
本文介绍了Datetime的默认约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我有桌子和记录。

当我更新表格中的任何字段时,我想要自动更新1个特定列。

例如.-当我更新员工详细信息时,

我想更新datetime列,以便我知道在此日期和它被更新的时间。

默认约束可以做到。

请建议并指导。

解决方案

是。默认约束对您来说已经足够了。只需将getdate()指定为记录创建/更新跟踪日期时间列的默认约束。


您好,



试试这样

  ALTER   TABLE 客户 ADD   CONSTRAINT  DF_Customers_updDate 
DEFAULT GETDATE() FOR updDate



问候,

GVPrabu


如果解决方案1和2不起作用,那么请尝试执行以下操作。



每次插入或更新写入功能GetDate()时都使用相应的列。

Dear Friends,

I have table and records in it.
When ever I update any field in table, I want automatically to update 1 particular column.
Eg.- When ever I update employee details,
I want to update datetime column so that i will come to know that on this date and time it is updated.
Can default constraint can do it.
Kindly suggest and guide.

解决方案

Yes. Default constraints is enough for you. Just assign getdate() as default constraint for your record create/update track datetime column.


Hi,

Try like this

ALTER TABLE Customers ADD CONSTRAINT DF_Customers_updDate 
DEFAULT GETDATE() FOR updDate


Regards,
GVPrabu


If Solution 1 and 2 dont works then try doing following things.

Every Time you Insert or Update write function "GetDate()" with the respective column.


这篇关于Datetime的默认约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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