SELECT cols.databasename AS DATABASE_NAME,
cols.tablename AS Table_Name,
Cast(alsp.currentperm AS BIGINT) AS TABLE_SIZE_BYTES,
” AS NUM_ROWS,
cols.columnname AS Column_Name,
” AS num_unique_val
FROM dbc.columns AS cols
JOIN ( select databasename,tablename, cast(sum (currentperm) as bigint) as currentperm from dbc.allspace group by 1 ,2 ) alsp
ON cols.tablename = alsp.tablename and cols.databasename = alsp.databasename
WHERE cols.tablename <> ‘All’;