How to run an SQL query from a scenario?

If you need to run SQL queries from your automation scripts, (for example: to check a transaction status or select automation parameters)

Automai robots can run any system command or batch file and get the output results in variables to be used in the automation script.

Make sure you have sqlcmd.exe utility installed where ScenarioBuilder or the robot (Injector, ScenarioStation, rTester, rWorker) is installed.

If the utility isn't installed in your machine, you can download it from here and install it in your test environment.

Once you are done, launch ScenarioBuilder and add the steps to your scenario. Here is an example:

1. Create and validate the results of the query by running it from the command line.

*Use sqlcmd parameters that fit your requirements.

For Example:

sqlcmd -E -S localhost\SQLEXPRESS -d automai -h -1 -s, -W -Q "set nocount on; select status from queue where queue_id=101")

2. Add "Run Command Line" action to your script.

SB sqlserver 1
3. Add a variable name to the Reg Expression property. You can add as many variables as needed.SB sqlserver 2