Library

How to execute SQL command with isql in command prompt

If you need to access Firebird database inside the batch/command line/PowerShell/bash script, the following technique will be useful:

echo select count(*) from rdb$database; | c:\path\to\isql.exe host/port:alias -user sysdba -pass masterkey
​In this case, isql.exe will be started, and command between echo and | will be passed as an input.

For example:

C:\HQbird\Firebird30>echo select count(*) from rdb$types; | isql.exe localhost/3050:employee -user sysdba -pas masterkey
Database: localhost/3050:employee, User: SYSDBA
SQL>
                COUNT
=====================
                  254

SQL>
C:\HQbird\Firebird30>