Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 trigger for time update

Author  Topic 

sudhirbharti
Starting Member

16 Posts

Posted - 2009-02-19 : 09:34:20
I am writing a sql trigger where i need to update the time in every 2 hour in following table

id ScheduleTime
1 5:01 AM 1
2 5:05 AM 1

so after 2 hour it should be

id ScheduleTime
1 7:01 AM 1
2 7:05 AM 1

any ideas?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-19 : 09:36:18
you should write a procedure with update statement and create a sql job to call this and schedule it to repeat for every 2 hours.
Go to Top of Page

sudhirbharti
Starting Member

16 Posts

Posted - 2009-02-19 : 09:43:53
thanks for the quick reply.

actually i have to pass the parameter (frequency period like 2 hours or 3 hours) from the programming, so i can't create the schedule job. because the hours is variable.

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-19 : 09:52:19
what determines your frequency value then?
Go to Top of Page

sudhirbharti
Starting Member

16 Posts

Posted - 2009-02-19 : 09:56:18
this is coming from the web page, so when a user enter the frequency time like 2 hours or 3 hours, then it update the column and update the column in every two hours from system date time
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-19 : 10:04:02
the update from webpage can be done by means of stored procedure. you can call the system stored procedure sp_add_schedule to achieve this by passing value from parameter

http://msdn.microsoft.com/en-us/library/ms186766(SQL.90).aspx
Go to Top of Page
   

- Advertisement -