July 6, 2009 at 2:30 am
Hi all,
I have a doubt on triggers in sqlserver. Can we create a trigger which should run on a particular time everyday?
Please clear my doubt.
Thanks
July 6, 2009 at 2:44 am
Trigger will be fired only corrospoding parent object gets events.
July 6, 2009 at 2:45 am
No a trigger will fire on data changes to that table inside the same transaction.
Maybe you can get the trigger to insert to a log table for a job to pickup on at a later point.
July 6, 2009 at 2:52 am
There are two types of triggers within SQL Server 2005 - DDL triggers and DML triggers. Basically, they require something to happen to the database to actually run them.
DDL triggers are Stored Procedures that are run when associated with a CREATE, ALTER or DROP command.
DML triggers are Stored Provedures that are run when associated with UPDATE, INSERT or DELETE statements for a particular table.
Therefore, an action has to be taken against the database or table to run a trigger.
What you want is a scheduled job, set to run a Stored Procedure at a set time. The Stored Procedure can be scheduled by using SQL Server Agent. Books OnLine has a section explaining SQL Server Agent, or this web site should also have articles on it.
BrainDonor.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply