The following approach is a simple approach.....although if I had more time I would insert the results into a temp table then select * where the count = 0 (null) or 1(single value). You may want to do add a table row count and then a count of the values to see if you have a mix of NULL and single value data
Have fun
Eric
declare
@tname sysname
declare
@cname sysname
declare
@sql varchar(1000)
declare
@count int
declare
TableCursor cursor
for
select
t.name, c.name
from
sys.objects t
inner
join sys.columns c on c.object_id = t.object_id
where
t.type = 'U'
order
by t.name, column_id
open
TableCursor
fetch
TableCursor into @tname, @cname
while
@@fetch_status = 0
begin
set @sql = 'select ''' + @tname+ ''', ''' + @cname + ''', count(distinct '+ @cname + ' ) from ' + @tname
execute(@sql)
fetch TableCursor into @tname, @cname
end
close
TableCursor
deallocate
TableCursor