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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Batch File Help Needed

Author  Topic 

Kowalski
Starting Member

3 Posts

Posted - 2008-12-11 : 06:50:28
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 5

c:
cd cd C:\root

REM Do the work

net use b: \\%1\c$ /user:user password
b:

cd
osql -Usa -Ppassword -s(local) -Dsitedb -ic:\temp\333283.sql



c:
C:\root\sleep 2

net use b: /del

As you can tell from the first line etc, IP adds are fed into a params text file and it carrys on dependent on how many IPs are in the file etc.

Any help greatly appreciated.

Cheers

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-12-11 : 07:34:52
moved from script library.

___________________________________________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.1 out!
Go to Top of Page

darkdusky
Aged Yak Warrior

591 Posts

Posted - 2008-12-17 : 07:35:18
Why not just loop through each server using a batch file running on your machine?

osql -Usa -Ppassword -sServerName -Dsitedb -ic:\temp\333283.sql
Go to Top of Page
   

- Advertisement -