I am trying to dynamically generate SQL INSERT scripts via Excel formulas
My Excel sheet looks as below.
Below is my formula
="INSERT INTO MYTABLE (ROLE_ID,GROUP,SUBGROUP) values('"&D8&"','"&$E$8&"','"&$F$8&"')"
Now, I want the expected output to be generated as below;
So basically, for Column G, I want the generated script to use data from Columns D, E and F. However, the information of Column D would change as per the current row, Columns E and F would repeat till we get an empty row (or as we can use value ‘0’ in Column D to identify that it should now use new values for GROUP and SUBGROUP)
1
You can use:
=IF(D8:D16=0,"","INSERT INTO MYTABLE (ROLE_ID,GROUP,SUBGROUP) values('"&D8:D16&"','"&E8:E16&"','"&F8:F16&"')")
0