When I used SQL identifier, it stopped working. The command line gets interpreted as following:
insert into stats select "1" as id, 'count of nulls in "UNIQUE_REFERENCE_NUMBER"' as checks, count("""UNIQUE_REFERENCE_NUMBER""") from points_of_interest."pointx_v2_National_Coverage_Sep21" where """UNIQUE_REFERENCE_NUMBER""" is null
I used select count("UNIQUE_REFERENCE_NUMBER") from a_table where "UNIQUE_REFERENCE_NUMBER" is null in SQL.
The following command runs but does not produce results as expected.
Execute Format('insert into stats select %L as id, %2$L as checks, count(%3$s) from %4$s where %5$s is null', i, 'count of nulls in '||col, col, t_name, col);
All columns have got capital letters in. How to ensure that the columns are double-quote when they are fed in as variables.