Run a SQL Seript againt Multiple SQL Server Instances

The VBScript below can be used to read a list of SQL Server instances from a text file and execute a SQL Script againt each of the instances:

Const SERVERLIST = “c:\serverlist.txt”
Const SCRIPT = “c:\errlog.sql”
Const ForReading = 1

Dim sCmd
Dim sLine

Dim oFSO
Dim oFSORead
Dim oShell

Set oFSO = CreateObject(“Scripting.FileSystemObject”)
Set oShell= CreateObject(“WScript.Shell”)

Set oFSORead = oFSO.OpenTextFile(SERVERLIST, ForReading)

Do While Not oFSORead.AtEndOfStream
sLine = trim(oFSORead.ReadLine)
sCmd = “osql -S” & sLine & ” -E -w4000 -i” & SCRIPT & ” -oc:\” & sLine & “.txt”


Set oFSO = Nothing
Set oShell = Nothing