views:

49

answers:

2

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.

A: 

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.

ajdams
Thank you, but I knew that and if i made step for ech db it will crash the server cause i run script takes several mints(its reindex script) and i have over 100 db.
Amr Elnashar
A: 

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.

Philip Kelley

related questions