My batch file will contain some thing like this :
set MUSER=root set MPASS=xprd123 set MHOST=22.214.171.124 set DB=DBName1 set MBIN=C:\Program Files\MySQL\MySQL Server 5.5\bin set scriptpath=D:\STATS_COLLECTOR "%MBIN%\mysql.exe" -u"%MUSER%" -p"%MPASS%" -h "%MHOST%" "%DB%" -e "set @2:='%scriptpath%'; source DBQuery1.sql;"
Content of DBQuery1.sql will be :
SELECT 'INNODB_OS_LOG_WRITTEN','QUESTIONS' UNION SELECT MAX(IF(variable_name = 'INNODB_OS_LOG_WRITTEN', VARIABLE_VALUE, NULL)) AS INNODB_OS_LOG_WRITTEN, MAX(IF(variable_name = 'QUESTIONS', VARIABLE_VALUE, NULL)) AS QUESTIONS FROM information_schema.GLOBAL_STATUS INTO OUTFILE '@2/stats.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' ;
I am not sure this is the way to pass path to the SELECT query inside DBQuery1.sql.
This code is not working.
I looked at other posts on passing path to batch file, but whatever I tried, I am not able to solve this issue.
When I execute the batch file, I am not sure if the path is getting passed into the sql file and if yes, why @2 is not getting the path passed.
Could anybody kindly help on this.