troubleshooting Question

Getting Column Count and value from Table name in schema

Avatar of Junior Vasquez
Junior Vasquez asked on
Microsoft SQL ServerSQL
21 Comments1 Solution183 ViewsLast Modified:
I've tried to ask this before, but maybe I was going about it in the wrong way.

If if have this query

select  
        s.[name]            'Schema',
        t.[name]            'Table',
        c.[name]            'Column',
        d.[name]            'Data Type'
from        sys.schemas s
inner join  sys.tables  t
on s.schema_id = t.schema_id
inner join  sys.columns c
on t.object_id = c.object_id
inner join  sys.types   d
on c.user_type_id = d.user_type_id
where s.name <> 'History'
and t.name not like 'CV%'
and t.name <> 'ServiceLog'
and t.name <> 'sysdiagrams'

that will get me the table names....

Then next part I need, is a loop that will go thru each table, then go and get every column name associated with that table. It will get the count of each column for each value..... including blanks and nulls.

I'm assuming that a cursor is needed, bt i'm looking for a better way than doing this for each table, as it needs to be automated.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 21 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros