Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. auto run a query in ms sqlserver

auto run a query in ms sqlserver

Scheduled Pinned Locked Moved Database
phpdatabasehelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    asdf1753
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • A asdf1753

      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

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups