I have a database that has a lot of tables with no data in them. I am wanting to find all of the tables that reference a specific column, but I want to make sure that the tables that show up have data and aren't empty. So far I have been able to show which tables have data using
select
t.name TableName, i.rows Records
from sysobjects t, sysindexes i
where t.xtype = 'U' and i.id = t.id and i.indid in (0,1) AND rows > 0
order by TableName;
I have also been able to show which tables reference the specific column that I am wanting by using:
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'COLUMN_NAME'
I just don't know how to combine the two.