SQLite Forum

Input from Windows Batch file
Login
Using Windows. How do I pass the output from a DOS batch file unto the command line?

I have a batch file with the following line:

echo SELECT * FROM [%1] ORDER BY RANDOM() LIMIT %2;

When I execute it in SQLite CLI:

sqlite> .shell  "D:/SQLite32/SCRIPTS/Techniques/N Random Records.BAT" tblSalesRevenue 10

D:\SQLite32>echo SELECT * FROM [tblSalesRevenue] ORDER BY RANDOM() LIMIT 10;
SELECT * FROM [tblSalesRevenue] ORDER BY RANDOM() LIMIT 10;
sqlite>

The batch file correctly constructs the SQL statement:

SELECT * FROM [tblSalesRevenue] ORDER BY RANDOM() LIMIT 10;

How do I execute that statement (without writing it to a file, or copy/paste)?