11.23 RunSql

Use this Knowledge Script to run SQL statements or stored procedures. You can enter the SQL statements to run, or you can supply the full path to a file from which to load SQL statements.

11.23.1 Setting Parameter Values

Set the following parameters as needed:

Parameter

How to Set It

Raise event if SQL statement succeeds?

Set to y to raise an event when the SQL statement is successful. The default is y. An event is always raised if an error occurs.

SQL Server name and instance if applicable

You can specify a SQL Server or a SQL Server and a named instance. Use the form “SQL\Instance”. By default, the default SQL Server instance on the computer where the Action runs is used.

SQL login

Specify the database user account that will run the SQL statements (for example, sa).

However, it is also possible to run this Knowledge Script using other user accounts that have been set up in the SQL Server of the managed client and been given permission to run SQL Knowledge Scripts through AppManager Security Manager.

NOTE:In general, permission to run specific SQL commands and statements is derived from the permissions granted to the login account you are using to run this Knowledge Script. However, the dbcc command can only be run by:

  • dbo account (SQL Server 6.x or 7)

  • db_backup operator account (SQL Server 7)

Load SQL script from a file?

Set to y to have SQL statements read from a file. Set to n to enter the SQL statements in the SQL Statements field. The default is n.

Full path to SQL script file

If you are entering SQL statements from a file, provide the complete file path (for example, F:\netiq\Sample.sql).

If the NetIQmc service is running as a system account, do not provide a path in the form of \\machine\dir\Sample.sql

SQL statement

Specify the T-SQL statement to be executed. The default is sp_who2.

Tip Unless you are entering very simple queries, typing SQL statements into this field may be error-prone. Use the Load SQL Script from a file parameter to read T-SQL statements from a file. Or, if you have an AppManager Developer’s license, you can check the Knowledge Script out of the repository, use the script editor to paste the desired SQL statements into the SQL Statement field, then check the modified Knowledge Script back in.

Save query results to a file?

Set to y to save query results to an external file. The default is n.

NOTE:Only the first 100 lines are written to the external file.

Full path to results file

Specify a full path to the file where you want query results saved.

Severity when SQL Statement fails

Set the event severity level, from 1 to 40, to indicate the importance of an event in which the SQL statement fails to run. The default is 10 (red event indicator).

Severity when SQL Statement succeeds

Set the event severity level, from 1 to 40, to indicate the importance of an event in which the SQL statement runs successfully. The default is 20 (yellow event indicator).