Add Birthday
how to use an update trigger?
1 replies to this topic
Gaurav Dutt
#1
|
Member
62
Points
|
Posted on
26 Mar 2012 07:04 AM IST
Hi,
I want to use an update trigger on my tab_ad table. I want to expire the ad after 10 days. Therefore i maintain a expirey_date column also. And I create an update trigger. But i don't know how to use this trigger now. I want it should work automaticaly.
Please help me.
Thanks.
|
SQL Server
924
views
Reply to this topic
|
Jahnavi N
#2
|
Member
164
Points
|
Replied on
18 Jun 2012 05:44 PM IST
Hi Gaurav Dutt,
Any trigger will fire automatically only when a DML operation done on associated table.
But here your requirement is to update table automatically with out doing any DML operation.
To achieve this we have two options
1. Windows service
2. SQL Jobs
second option is better.
Steps to implement.....
Step-1:
Write SQL query to update Table
*Move expired records into expiry_date table from tab_ad
*Remove expiry records from tab_ad table
Step-2:
Create a Job
Add one step in that job
Place your SQL Query to step
Step-3:
Schedule the Job
When to start job and the frequency like to run job(ex: every 1 hour).
I hope this will help you.
Thanks,
Jahnavi
|
Reply to this topic
|
|
|