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

        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 <> 'History'
and not like 'CV%'
and <> 'ServiceLog'
and <> 'sysdiagrams'

Open in new window

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.
Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 21 Comments.
Start Free Trial
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