Answer the question
In order to leave comments, you need to log in
How to correctly execute sql query using bat file?
Good day.
There is a task: to run a daily sql query using a bat file. firebird 2.1 server on localhost. I use the built-in isql utility. I'm trying to run a bat file, but it returns empty results, the same request works through cmd. What is wrong? Maybe through something else you need to make a request? I'm not familiar with PowerShell.
set isql="C:\\Program Files(x86)\\FireBird\\FireBird_2_1\\BIN\\isql.exe"
CONNECT '127.0.0.1/3080:E:\Torgovlya54\MAIN.GDB' USER 'sysdba' PASSWORD 'masterkey';
SELECT C.CODE AS "Табельный", C.NAME AS "Ф.И.О.", T.TRANZDATE AS "Дата", max(T.TRANZTIME) AS "Время", T.INFOSTR AS "Карта" sum(T.SUMM) AS "Сумма" FROM DOCUMENT D LEFT JOIN TRANZT T ON D.ID = T.DOCUMENTID JOIN CLIENT C ON D.CLIENTID = C.ID WHERE T.TRANZDATE = cast('now' as date) and D.STATE = 1 AND D.ISFISCAL = 1 AND D.CLIENTID >=0 AND T.TRANZTYPE = '36' GROUP BY C.CODE, C.NAME, T.TRANZDATE, T.INFOSTR;
set outputfile=outputfile.txt
echo %mydt% >> %outputfile%
Answer the question
In order to leave comments, you need to log in
Try like this:
set isql="C:\\Program Files(x86)\\FireBird\\FireBird_2_1\\BIN\\isql.exe"
echo ^
SELECT C.CODE AS "Табельный", C.NAME AS "Ф.И.О.", T.TRANZDATE AS "Дата", max(T.TRANZTIME) AS "Время", T.INFOSTR AS "Карта" sum(T.SUMM) AS "Сумма" FROM DOCUMENT D LEFT JOIN TRANZT T ON D.ID = T.DOCUMENTID JOIN CLIENT C ON D.CLIENTID = C.ID WHERE T.TRANZDATE = cast('now' as date) and D.STATE = 1 AND D.ISFISCAL = 1 AND D.CLIENTID >=0 AND T.TRANZTYPE = '36' GROUP BY C.CODE, C.NAME, T.TRANZDATE, T.INFOSTR; ^
| %isql% 127.0.0.1/3050:E:\Torgovlya54\MAIN.GDB sysdba masterkey > outputfile.txt
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question