sweetaz
asked on
How to run a SQL query for all machines in an OU
I have a SQL query that I need to run on all machines in an OU in a W2k3 Server Windows XP environment.
The .bat is located in the netlogon share of the DC and is as follows:
***********
cd\
cd Program Files\Microsoft SQL Server\80\Tools\Binn
OSQL -S (local) -d BOData -E -i \\dc\netlogon\query1.sql
REM KEY-S [server] -d [database] -E [trusted connection] -I [input file]
OSQL -S (local) -d POSLocal -E -i \\dc\netlogon\query1.sql
REM KEY-S [server] -d [database] -E [trusted connection] -I [input file]
exit
************
I want to run this without user input and users do not have admin privelges. Can anyone explain to me a way to achieve this?
Regards
SweetAz
The .bat is located in the netlogon share of the DC and is as follows:
***********
cd\
cd Program Files\Microsoft SQL Server\80\Tools\Binn
OSQL -S (local) -d BOData -E -i \\dc\netlogon\query1.sql
REM KEY-S [server] -d [database] -E [trusted connection] -I [input file]
OSQL -S (local) -d POSLocal -E -i \\dc\netlogon\query1.sql
REM KEY-S [server] -d [database] -E [trusted connection] -I [input file]
exit
************
I want to run this without user input and users do not have admin privelges. Can anyone explain to me a way to achieve this?
Regards
SweetAz
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Younghv I have pstools installed but didnt think to use psexec.
Cheers
Sweetaz
Cheers
Sweetaz
Hoo Ahh!
Thank you for the points.
Sysinternals stuff is so good, I would pay for it (but don't tell Bill Gates).
Vic
Thank you for the points.
Sysinternals stuff is so good, I would pay for it (but don't tell Bill Gates).
Vic
cd\
xcopy "\\dc\netlogon\query1.sql"
cd "%ProgramFiles%\Microsoft SQL Server\80\Tools\Binn"
OSQL -S (local) -d BOData -E -i query1.sql
REM KEY-S [server] -d [database] -E [trusted connection] -I [input file]
OSQL -S (local) -d POSLocal -E -i query1.sql
REM KEY-S [server] -d [database] -E [trusted connection] -I [input file]