Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
slymonkey
Starting Member
5 Posts |
Posted - 2006-06-22 : 10:37:17
|
| I have a script, lets call it BOB. BOB updates multiple parts of a database (adds fields, creates new tables, etc.). I want to apply BOB to multiple databases without having to manually do it for each one. Is it possible to automate this process in the following way.For Every Database in server instance <name>Apply BobAny help provided would be helpful |
|
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2006-06-22 : 16:39:16
|
| rvolk provided some help 2 years ago with this exactly problem. Here's what you need, it uses a for loop in dos to go through each server/db in your servers folder.1. Put all your script files into one folder.2. Create a plain text file called servers.txt, and put each server name on one line: Server1Server2Server3…etc. Use the following command: for /F %z in (servers.txt) do for %a in (\scriptfolder\*.*) do osql –E –n –S%z –i %a That will run all scripts in that folder for all servers in that file. If you put this in a batch file, replace each % with %%.Mike"oh, that monkey is going to pay" |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-06-24 : 02:31:00
|
| SP_MSFOREACHDB ??Undocumented though ...Kristen |
 |
|
|
|
|
|