![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello. I have a WSH script which reads in a list of servers from my database (RecordSet("serverName")) and then runs a query against that SQL Server (DoSomething.sql). Unfortunately in my environment there are two possible SQL logins that have rights on our server. How could I check to see if Login1 or Login2 has rights before running the SQLCmd using Login1 or Login2? Const SQLCMD = "sqlcmd -i -b DoSomething.sql -t 6015 " Const SQLLogin1 = "-U Login1 -P MyPassword " Const SQLLogin2 = "-U Login2 -P MyPassword " intResult = WshShell.Run(SQLCMD & SQLLogin1 & "-S " & RecordSet ("ServerName"),0,False) For some reason intResult is not populated after running. I apologize for putting this in the sql and wsh group, I was not quite sure where it should be placed (please don't flame me). Any help would be greatly appreciated. Hartman_Ralph (AT) hotmail (DOT) com |
#3
| |||
| |||
|
|
Hartman_Ralph (AT) Hotmail (DOT) com schrieb: Hello. I have a WSH script which reads in a list of servers from my database (RecordSet("serverName")) and then runs a query against that SQL Server (DoSomething.sql). Unfortunately in my environment there are two possible SQL logins that have rights on our server. How could I check to see if Login1 or Login2 has rights before running the SQLCmd using Login1 or Login2? Const SQLCMD = "sqlcmd -i -b DoSomething.sql -t 6015 " Const SQLLogin1 = "-U Login1 -P MyPassword " Const SQLLogin2 = "-U Login2 -P MyPassword " intResult = WshShell.Run(SQLCMD & SQLLogin1 & "-S " & RecordSet ("ServerName"),0,False) For some reason intResult is not populated after running. I apologize for putting this in the sql and wsh group, I was not quite sure where it should be placed (please don't flame me). Any help would be greatly appreciated. Hartman_Ralph (AT) hotmail (DOT) com Use True as the third parameter (bWaitOnReturn) in the .Run call. *Then* the shall can return the exit code of the command. |
![]() |
| Thread Tools | |
| Display Modes | |
| |