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 |
|
Kowalski
Starting Member
3 Posts |
Posted - 2008-12-11 : 07:26:01
|
| Hi, I have a sql file that needs run on over a hundred different machines.At the moment my only options on getting this script ran on each machines db is to log on to the PC and execute either through quary analyser or command line OSQL, both options are rather time consuming so my attention has now shifted to a batch file (which i have limited experience of)Now my plan was to dump the required SQL file in say C:\temp on the remote machine, then execute the batch on my machine which would then map to the remote machine and execute the script via OSQL, easier said than done sadly.Here is the script I have so far, as I said, im fairly new to this so go slow Batch:ping %1 -n 5c:cd cd C:\rootREM Do the worknet use b: \\%1\c$ /user:user passwordb:cd osql -Usa -Ppassword -s(local) -Dsitedb -ic:\temp\333283.sqlc:C:\root\sleep 2net use b: /delThe batch works by calling an IP from parameter text file.Any help greatly appreciated.Cheers**Mods, originally posted ins cript library, thought it may be best to report here, thanks |
|
|
darkdusky
Aged Yak Warrior
591 Posts |
Posted - 2008-12-15 : 05:09:07
|
| If you make each of your remote servers a linked server you should be able to run you file from a single location.You could also create a stored procedure to execute your script against all the linked servers using:Select srvname from sys.sysservers to list them all.This will should be easier to maintain. |
 |
|
|
|
|
|