如何使用当前系统日期在sql数据库中编写更新触发器 [英] How to write update trigger in sql database with current system date

查看:271
本文介绍了如何使用当前系统日期在sql数据库中编写更新触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我已经为表编写了触发器,但是我想在系统日期等于给定日期时执行该触发器.

我知道触发器可以在插入,更新,删除中起作用.
因此,有什么方法可以执行带有日期检查的触发器.请帮帮我.

谢谢.

Hi everybody,
I have written a trigger for a table, but i want to execute that when the system date is equal to the date that given.

I know trigger can work in insert, update, delete.
So is there any possible way to execute the trigger with the date check.Please help me.

Thanking you.

推荐答案

不,没有.您必须编写服务或其他方式来检查日期.
No, there''s not. You''d have to write a service or something else to check the date.


触发词本身表示在某个事件发生时会发生某些事情.在数据库世界中,可以是插入",更新"或删除".

根据您的情况,它们与可以调用触发器的三个事件都不相关.因此,它不会被调用.
根据CG的建议,您需要具有Windows服务或某种计划程序,以检查指定条件并执行某些查询.
Trigger word itself says that something happens when a certain event occurs. In DB world it can be, Insert, Update or Delete.

Based on your condition, they are not related to either of the three events that can call a trigger. Thus, it would not be called.
As suggested by CG, you need to have a Windows Service or some kind of Scheduler that will check for the specified condition and execute certain queries.


请考虑考虑SQL Server JOB,而不是触发,何时可以帮助您解决挑战
Please think about an SQL Server JOB, instead of Triggers, when may help you to resolve your challenge


这篇关于如何使用当前系统日期在sql数据库中编写更新触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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