How to run script on multiple databases

I have a SQL maintenance script that I want to run on multiple databases instead of having to run it manually against each database.  Is there a way of creating a job or something to allow this to happen?

Thank you in advance for your help.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marten RuneSQL Expert/Infrastructure ArchitectCommented:
If you create a job, you can have one jobstep for dbOne, and let jobstep two take care of dbTwo, etc etc


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cjrcomputersAuthor Commented:
I was hoping I wouldn't have to create a step for each database as there's 11 of them, but if thats the only way I guess I'll have to.
Have you considered using the sp_msforeachdb procedure?
Check these links for details: 
cjrcomputersAuthor Commented:
Well I would use that procedure, but I don't want to do it on all of the databases on the server.  I think I'll just have to created a job with a step for each database.
I guess you didn't read the links, you can selectively run the script based on the database name. check this part of the first link:
EXECUTE sp_msforeachdb 'USE ?
IF DB_NAME() NOT IN(''master'',''msdb'',''tempdb'',''model'')

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.