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
 General SQL Server Forums
 New to SQL Server Programming
 Alternate for sql job?

Author  Topic 

pushp82
Yak Posting Veteran

83 Posts

Posted - 2012-07-02 : 01:11:15
Hi,

I have two times in a table and my exercise is:
If time difference cross 10 minutes than fire a trigger.

How can I accomplish this task?

Is SQL Job only solution?

Actually time1 is login time and time2 if of last event time so if there was no event fired since 10 minutes then logout the member.
What can be the easiest way for this task?
is there any way to calculate time diffrence automaticaly?

Please help!
Thanks,
Pushp

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-07-02 : 06:21:56
The time difference is a simple query.
The natural way of doing this would be a job. You could even create a job on login which starts 10 minutes later and forces a logout if stil logged in. Probably wouldn't want to have many of those running though.

Could also be done from a window task.

It depends on the application but for web sites usually the message from the user always goes through a task (SP if in the database) which checks the status. If more than 10 minutes since the login this would set to logged out and return otherwise the last interaction time is updated. In that way you don't have to worry about setting the status - the user is only logged in if they log in and interact with 10 minutes - so the last interaction time becomes part of the status.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -