aak97 Posted June 10, 2003 Posted June 10, 2003 I'm starting a project of my own, it's a simple forum. I know there're tons out there, but I just wanna polish my skills a bit. Anyways, in my forum, when user registers they will have to give a valid email address. To verify this email address, I'll send them an email, and if they click on the link on that email, it'll activate their accout. If the user does NOT activate his account in 48hrs. His account will be deleted from the database. Here is the question: Since I Saved the info the user provided to a dbase in SQL Server 2k before I sent the email for verification, If the user does not activate the account in 48hrs, I need some way to remove that ROW in the database table. How can I do this automaticlly? There is actually 2 tables, one table is the MEMBERS table and it is in relation with another table call Verification (this is where I stores the verification string and the Time(smalldatetime) that account is created). the common key is the username. If the user activated his account within 48hrs, the entry in the Verification table will be removed by the verification page. is there a function or a way to write a script in SQL Server 2k to automate this task? this is my first time working with SQL Server, any good book recommandations (ones with lots of examples with TSQL and some basic functions I can use with SQL Server)? TIA aak97:D Quote
*Gurus* Derek Stone Posted June 11, 2003 *Gurus* Posted June 11, 2003 Insert the date and time of the initial registration in a field and check it when the user goes to verify the registration. If the verification period has passed delete the user's records. Placing code like this in a loop, timer or trigger would be fairly inefficient unless the registered:non-activated ratio was extremely high; a preferable solution is to perform this action when another new user goes to register. Quote Posting Guidelines
wyrd Posted June 11, 2003 Posted June 11, 2003 Cleaning up databases is usually done through an automated task (job). You can read about that here; http://msdn.microsoft.com/library/en-us/adminsql/ad_automate_4v1v.asp?frame=true Also look up the commands sp_add_job, sp_add_jobschedule, sp_add_jobstep and sp_add_jobserver. Usually scheduled tasks are performed once a day when traffic to the web site is fairly low (3am in the morning for example). In this case just add a job that does the following; DELETE FROM Verification WHERE sign_up_date < DATEADD(d, -2, GETDATE()) .. I'm sure you get the idea. Quote Gamer extraordinaire. Programmer wannabe.
aak97 Posted June 11, 2003 Author Posted June 11, 2003 ar... Jobs... that's what I'm looking for! Thanks a lot! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.