-1

I'm quite a newbie to the topic databases. It may be that the topic already exists, but I don't even know how to search for it. How to query and so on seems to be no problem. And how to write a trigger on an INSERT/DELETE/UPDATE statement is known too.

I would like to know if it is possible to execute some code to generate a data row every day once at a specific time without an external programm.

Thanks, Chris

PS: I'm from Germany, so don't get angry about my expressions, please^^

Giannis Paraskevopoulos
  • 18,261
  • 1
  • 49
  • 69
  • http://stackoverflow.com/questions/5471080/how-to-schedule-a-job-for-sql-query-to-run-daily – Mat Richardson Sep 29 '14 at 11:35
  • Well, I guess I will mark the question as answered. Thanks for the clear answer. I seem to have the Express Version which does not have the server agent, because I'm logged on as 'sa' at the database engine and I can't see the node for it. So I will try for the version with the Windows scheduler. – user2688664 Sep 30 '14 at 08:02

1 Answers1

2

If you are not in an Express Edition you may create an SQL Job to do that.

  • Open SSMS

  • Drill Down your server instance

  • Drill Down SQL Server Agent

  • Right click Jobs folder

  • Chose New Job

  • Fill in the details in the General Tab

  • Go to the Steps tab

  • Click New

  • Enter a name, choose which db to run against and enter your SQL statement.

  • Go to Schedules tab

  • Add a schedule to run once each day at the time you wish.

Giannis Paraskevopoulos
  • 18,261
  • 1
  • 49
  • 69
  • why -1? One can argue how smart it is to use this part - the agent -for this, but it is a correct answer. Express does not have the agent, so there is no scheduler. Hardly the fault of the poster of the answer. – TomTom Sep 29 '14 at 11:39
  • @TomTom Thanks for the support. Not to mention that i did note myself that it would not work on the Express edition. – Giannis Paraskevopoulos Sep 29 '14 at 11:53
  • I just wanted to point out that this "not in express edition" was not snippy from you. I prefer not to use the agent for an in application thing, but the answer IS correct. – TomTom Sep 29 '14 at 11:54
  • @TomTom Well, in my mind a thing that happens at a specific time each day and it is marked as a db issue (not a mention to a client application) seems that it must be done with a scheduler, sql or windows. – Giannis Paraskevopoulos Sep 29 '14 at 11:56
  • Absolutely, I just keep them out of SQL Server. Mostly to do with "I dont want the hassle of tracking what jobs run" while a scheduler on the application server can be installed with the msi file. I use the agent only for server level administrative tasks (check, backup etc.). Makes a clear responsibility separation. – TomTom Sep 29 '14 at 11:58