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
 db self check

Author  Topic 

elic05
Yak Posting Veteran

62 Posts

Posted - 2010-11-23 : 12:53:00
is their a way
that i can tell the db to check a specific field in a table
at set intervals

i want it to run a check every 2 minutes
to check for users that their rows were not updated for two minutes
i what these users to be removed from the table

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-23 : 12:54:43
Yes you can do this via a SQL Server Agent job.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-23 : 12:56:59
quote:
Originally posted by elic05

is their a way
that i can tell the db to check a specific field in a table
at set intervals

i want it to run a check every 2 minutes
to check for users that their rows were not updated for two minutes
i what these users to be removed from the table




What?

Your goal is an empty database?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

TimSman
Posting Yak Master

127 Posts

Posted - 2010-11-23 : 12:59:40
2 minutes? Better make the bathroom breaks real quick.
Go to Top of Page

elic05
Yak Posting Veteran

62 Posts

Posted - 2010-11-23 : 14:19:31
I will explain.

i build a chat room
its built by flash/actionscript that connects the server throuth aspx/vb.net

everyone that connects to the room with a username is listed in the users table
since the server cant talk to the client
i have a function on the client (flash object) that sends a request to the server to get data
the data:
a. new messages
b. new users
c. users that left the room
on every user request i update in the users table the time of the last request
the request is made every 2 seconds


if a user use the logout button
i can inform the server (using actionscript) to remove him from the users table
but if he just closes the browser
the server cant know that this user is no longer connected
unless the server checks from time to time to see if some user dont request data anymore

therefore i have a field in the users table that is updated on every request by the time of the last request

and i want the server to check from time to time (lets say every 2 minutes) what was the last time of request of every user
if their was no request for the last minutes
the user is not connected he closed the browser.


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-23 : 15:22:41
Do you store the connection time?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

elic05
Yak Posting Veteran

62 Posts

Posted - 2010-11-23 : 17:29:23
i store the last request time of the user
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-23 : 17:31:32
well post the DDL of the table(s) you are using

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

elic05
Yak Posting Veteran

62 Posts

Posted - 2010-11-23 : 17:42:02
I cant see my database in the SSMS (i dont know why)

i have there 3 fields

table Name: users
userName, nvarchar(20)
lastRequestTime, time(7)
lastMsgId, int
Go to Top of Page
   

- Advertisement -