Dear All,
I would like to create the script to get all the columns(Pivot) of each tables within a schema.


Code:
select colname,tabname from syscat.columns
WHERE TABSCHEMA like 'MY_SCHEMA%'
EMP
------
EMPNO
ENAME
JOB
SAL

The output should be like as follow from above table

SELECT EMPNO,ENAME,JOB,SAL FROM EMP;

The following Script ran ok which gave me the count of each table and it works now I like to compare the values of each column|table by other schema.
Hope it make sense appriciate you help

HTML Code:
SELECT 'SELECT '''||TABSCHEMA||''','''||TABNAME||''' AS TABLE_NAME'||' ,COUNT(*) AS NUMBER_OF_RECORDS FROM'||' '||TABSCHEMA||'.'||TABNAME||' UNION'
  FROM SYSCAT.TABLES WHERE TABSCHEMA like 'MY_SCHEMA_%';
Kind regards,
Farhan