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 |
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-09-04 : 09:50:17
|
| [code]Hi all,I have a table called COMPUTERS where all computer names are stored.I use the computer name of the table to :1. net use \\$$\ipc$ /U:user pass (each computer)2. under C drive there's "congfig.bat" file where I need to extract a value for each computer. Note i need to access and read from this file for each computer.I'm actually not sure how to manage this process.Any suggestions will be appreciated!Thanks,[/code]--------------------------Joins are what RDBMS's do for a living |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2012-09-04 : 11:17:07
|
| You could complete this task in a stored procedure - using the xp_cmdshell. This requires some elevated rights.Alternately , you can manage this via Powershell What is more conveniant for you?Jack Vamvas--------------------http://www.sqlserver-dba.com |
 |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-09-04 : 12:18:47
|
| I think a stored procedure will be best for my case because the way this is executed is calling the .sql script that has all statements including the procedure i will write for it.Do you think a procedure will be better than a cursor?--------------------------Joins are what RDBMS's do for a living |
 |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2012-09-05 : 03:39:17
|
| Step 1- loop through the list of computers in the table. Step 2 - Execute the commandsStep 3 - add some exception reporting and log the results to a Log tableA potential problem I see is in your step 2 - is the the config.bat file your loading just sitting on the server or is a copy sitting on every computer?Jack Vamvas--------------------http://www.sqlserver-dba.com |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-09-05 : 04:14:03
|
I think it would be cleaner to write a shell script that got the information and then it wrote it (using sqlcmd or similar / powershell with a crud sp)Putting your (non database) admin tasks in the db always makes me shudder a bit.Transact CharlieMsg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. http://nosqlsolution.blogspot.co.uk/ |
 |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2012-09-05 : 18:53:45
|
| I'd generally agree with the other Charlie & Jack - run the SQL to get the machine names into a text file then do all your script work outside the DB.However, what I really wanted to ask you is how did the thing you want to get from congfig.bat get there in the first place? Is there some other source of truth that means you don't have to do this? |
 |
|
|
|
|
|