i'm trying create overviews , dynamic select statements database.
select 'select ''' + table_schema + '.' + table_name + ''', count(*) [' + table_schema + '].[' + table_name + '] union all' information_schema.tables table_type != 'view' , (select count(*) table_schema.table_name) > 0 i'm stuck on part: select count(*) table_schema.table_name
throws invalid object name
is there way can make work dynamically?
if want exclude tables no rows result set, add having count(*) > 0 clause generated sql:
select 'select ''' + table_schema + '.' + table_name + ''', count(*) [' + table_schema + '].[' + table_name + '] having count(*) > 0 union all' information_schema.tables table_type != 'view'
Comments
Post a Comment