I have sql server script and i want to automatic run it on the database 开发者_高级运维every week.
any help.
i tried sql server agent job but i have alot of data bases on my server and i should make step to every database and it will run in the same day and same time.
You were on the right track, in management studio:
(1) Find SQL Agent and right click and select Job.
(2) Give you job a name and description and then choose the Steps option on the left
(3) In the Step options you can name your step, insert your script code, AND select which database you want the job to be performed on.
(4) Next go to the Schedules option on the left and designate how often you want the job to run (pretty self-explanatory)
(5) The Alerts, Notifications, etc options should also be utilized if you want to be informed on failure/success/etc.
That's it pretty much.
If you want one job with one step that performs the same action on every database (or perhaps a subset of databases), consider using system procedure sp_msForEachDB. I spelled out one way to use this in this prior answer.
精彩评论