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.
| Author |
Topic |
|
abacusdotcom
Posting Yak Master
133 Posts |
Posted - 2005-04-18 : 13:13:15
|
| Hi All,I have 2 tables where i want to make decisions from.The first table is user tableAppUser---------Userid var...Logged bit ...username....the second table userinfo.........userid varch...ast_page_visit_time datetime...Logged will be set to 1 when the user logs successfullyand for every page the user browses, the datetime of visit willbe updated into userinfo.so i have two tables, so i want my query to read thru appuser take d userid check it in userinfo and check d date if its above 20 minutes, if above 20 minutes, check logged to 0. then for next, until end record. The basis of the query will if logged = 1 in appuser table.This is my sample query, but i know it wont workCREATE PROCEDURE UpdateCRIAS update appusers set Logged = 0 where UserID in (select userid from userinfo) and (datediff(mi,(Select last_page_visit_time from userinfo),getdate())) > 20Thanks.I sign for fame not for shame but all the same, I sign my name. |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2005-04-18 : 13:28:33
|
| [code]update appusersset Logged = 0from appusers join userinfo on appusers.userid = userinfo.useridwhere appusers.Logged = 1 and userinfo.last_page_visit_time < dateadd(mi,-20,getdate())[/code]CODO ERGO SUM |
 |
|
|
abacusdotcom
Posting Yak Master
133 Posts |
Posted - 2005-04-18 : 13:55:45
|
| Hi All, DBA Colonel thanks for the post.I have a problem now, i tried o make the query a scheduled tasks in sql server. I have created a job using the query above, the problem am having now sql server is saying "SQLServerAgent is not currently running so it cannot be notified of this action". Please, how can make d tasks work?--Lekan aka abacusdotcomI sign for fame not for shame but all the same, I sign my name. |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2005-04-18 : 14:07:27
|
| Start the SQLServerAgent.If you don't know how to do this, read about SQLServerAgent in SQL Server Bookd Online.CODO ERGO SUM |
 |
|
|
abacusdotcom
Posting Yak Master
133 Posts |
Posted - 2005-04-18 : 14:08:12
|
| Thanks A LotI sign for fame not for shame but all the same, I sign my name. |
 |
|
|
abacusdotcom
Posting Yak Master
133 Posts |
Posted - 2005-04-18 : 14:29:33
|
| Hi,Can I set the scheduled time to 20 min. SQL server kept making the interval an hour. why?I sign for fame not for shame but all the same, I sign my name. |
 |
|
|
|
|
|
|
|