auto run a query in ms sqlserver
-
hi is there any one help me to run a query in MS Sqlserver periodical for example delete some data every 24hour that be independent from asp or php and etc... i want that MS Sqlserver run it itself. thanks
Sql Server has the ability to schedule tasks inside and run them itself. If you are using SQL Server 2000, you will need to expand the Management node under your database, then expand SQL Server Agent and select Jobs. Right click and select New Job... In the General tab enter a name. Select the Steps tab and New... to create a new task. Suppose that you want to run a particular delete (
delete from myTab where @created > dateadd(dd, getdate(), 2)
). Give the step a name and leave the type as Transact-SQL Script (TSQL). Choose the database that you want to run the task against and enter the SQL in the Command textbox. Click OK. Next, go to the Schedules tab and create a new schedule. To change the times when it runs, select the Change button and set your schedule as appropriate.Deja View - the feeling that you've seen this post before.