Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All.
PLEASE CAN YOU HELP WITH THIS? THANKS IN ADVANCE.
I NEED LOAD SQL COMMANDS LIST FROM EXCEL FILE, RUN SQL COMMANDS LIST AND SAVE ALL THE RESULTS IN THE SAME TABLE OR FILE
MY EXCEL SOURCE FILE IS AS:
EXCEL FILE SOURCE | |||
TABLE_CATALOG | TABLE_SCHEMA | TABLENAME | SQL COMMAND |
DATABASE_A | DBO | TABLE_A | SELECT COUNT (*) FROM DATABASE_A.DBO.TABLE_A |
DATABASE_A | DBO | TABLE_B | SELECT COUNT (*) FROM DATABASE_A.DBO.TABLE_B |
DATABASE_A | DBO | TABLE_C | SELECT COUNT (*) FROM DATABASE_A.DBO.TABLE_C |
MY DESTINATION QVD OR CSV FILE FOR TAGRGET RESULTS IN ONE UNIQE TABLE IS:
TAGRGET RESULTS IN ONE UNIQE TABLE | |||
TABLE_CATALOG | TABLE_SCHEMA | TABLENAME | COUNT_OF_ROWS |
DATABASE_A | DBO | TABLE_A | 100 |
DATABASE_A | DBO | TABLE_B | 200 |
DATABASE_A | DBO | TABLE_C | 300 |
Load_Count_Origin_Queries:
LOAD
Id_TableQueries,
TableAutSelect_TableQueries,
ActQuery_TableQueries,
QueryName_TableQueries,
QueryDesc_TableQueries,
Server_TableQueries,
Table_Catalog_TableQueries,
Table_Name_TableQueries,
Table_Schema_TableQueries,
QueryPt1_TableQueries,
QueryPt2_TableQueries,
Query_TableQueries,
now() as DateTime_TableQueries
//DEFINE ROUTE OF EXCEL SOURCE FILE & SPECIFIC SHEET
FROM $(Var_Table_List_Folder)\Table_List.xlsx (ooxml, embedded labels, table is OrgTableQueries);
//STORE LOADED DATA INTO TEMPORARY TABLE & QVD FILE
STORE Load_Count_Origin_Queries into $(Var_Qvd_Files_Folder)\Load_Count_Origin_Queries.qvd (qvd);
//STORE LOADED DATA INTO TEMPORARY TABLE & CSV FILE
STORE Load_Count_Origin_Queries into $(Var_Qvd_Files_Folder)\Load_Count_Origin_Queries.csv (txt);
MyTab:
LOAD now() as DateTimeSQLCmd_Qry1_T,
QueryName_TableQueries, Query_TableQueries
RESIDENT Load_Count_Origin_Queries where ActQuery_TableQueries='Yes';
FOR i = 0 to NoOfRows('MyTab')-1
LET QueryName_TableQueries = peek('QueryName_TableQueries', $(i), 'MyTab');
LET Query_TableQueries= peek('Query_TableQueries', $(i), 'MyTab');
// Put the SQL here or call it as A SUB
Query_TableQueries:
SQL $(Query_TableQueries);
STORE MyTab into $(Var_Qvd_Files_Folder)\MyTabIN.qvd (qvd);
STORE MyTab into $(Var_Qvd_Files_Folder)\MyTabIN.csv (txt);
NEXT i