[quote=引用 1 楼 yenange 的回复:] 不太明白你的逻辑, 但应该不需要触发器, 加 2 个计算列就可以了, 类似: alter table tableName add gl_result AS case when tzrq>getdate() then gl+1 else gl end 具体的细节你自己去完成吧
alter table tableName add gl_result AS case when tzrq>getdate() then gl+1 else gl end
不太明白你的逻辑, 但应该不需要触发器, 加 2 个计算列就可以了, 类似: alter table tableName add gl_result AS case when tzrq>getdate() then gl+1 else gl end 具体的细节你自己去完成吧
[quote=引用 5 楼 a504191479 的回复:] [quote=引用 1 楼 yenange 的回复:] 不太明白你的逻辑, 但应该不需要触发器, 加 2 个计算列就可以了, 类似: alter table tableName add gl_result AS case when tzrq>getdate() then gl+1 else gl end 具体的细节你自己去完成吧
我觉得你这个问题的关键应该是定时触发,比如通过作业来实现,而且触发的时间点也很有讲究,触发器不合适。 但是,你那个具体的计算逻辑我觉得有漏洞,比如调整日期是2018年12月份,同时总共天数-365正好是30,那调整天数就变成了2019年1月份,难道到2019年1月份又再次进行计算,然后就一直后续每月循环下去?
22,207
社区成员
121,730
社区内容
加载中
试试用AI创作助手写篇文章吧