Script Template

Live Demo Free Edition
(Monitor 10 Devices)
  Download Now

Custom Script Templates - MSSQL Command output

Title MSSQL Command output
Description Getting an integer value from a local or remote MSSQL DB Query server using sqlcmd utility.
UseCase -
Prerequisites sqlcmd utility should have been installed in the server where OpManager is and "sqlcmd" must be a recognized command.

The remote SQL server should not be configured with dynamic ports.
The firewall should be disabled. It should not prevent OpManager server's access to remote SQL server's port.
Limitations We can query only two columns from a table., provided the second column should return an integer value.

For better performance - query should not return more than 20 rows

cscript ${FileName}.vbs ‹sqlserver›\‹instance,port› ‹dbusername_optional› ‹dbpassword_optional› ‹dbname› ‹query›
Arguments sqlserver: Sql Server name
instance: Instance name
port: Mssql Port
dbusername_optional: Username (not required for local server)
dbpassword_optional:Password (not required for local server)
dbname: DataBase Name
query: Query to execute
Example cscript ${FileName}.vbs\SQLSERVER,1433 sa mssql12 EmployeeDB "select emp_name,emp_salary from Employee"