Hi everyone,
I'm creating a online e-letter registration system. That saves 'temp' values to a 'temp' table, and then sends a automated email to the subscriber, from which he/she can then except, or decline the registration.
bu now i want to create a procedure, or some kind of funciton in T-SQL that will be scheduled to run every 2 or so hours, to check and see if there is any values in the temp table that is older than 24hours, and if that values is greater than 24hours, it must delete that values from the temp table... so that the temp table doesn't become too full of old, outdated data.
Please help.
Thanks
OK, thats an easy thing, but we need more input to see what you will have to do. Which SQL Server are you using ? The delete part would be the easiest, as it would turn out to be something like
DELETE FROM SomeTable Where DATEDIFF(dd,SomeDatecolumn,GETDATE()) >= 1
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||what do you mean, "what SQL server am I using?" SQl Server 2005....|||OK, it would be interesting to know which SKU you are using (in detail if you use Express or not) because with any other edition than Express you would be able to use the SQL Server agent as well to plan the execution of your procedure. You will not need to create a stored procedure as the statement above will run fine using a simple job step with an TSQL execution element. Once the job step is created you will just have to schedule the execution of the job and you are done.
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||no, this is not SQL Server Express, It can be either the Developer Edition, or the Enteprise Edition...|||Then go straight ahead by creating a job, defining a schedule and inserting one step for executing the TSQL statement mentioned above.
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de