Table Name with Column Count
Well recently I needed a query that would display all the table names along with a column count so I just tossed this one together. I did some surfing around and I noticed that some folks have turned queries very similar to this into a function which might be the route that I pursue as well. However this is just a simple SELECT statement as you can see below.
SELECT t.name AS [Table Name] ,COUNT(c.name) AS [Column Count] FROM sys.tables t JOIN sys.columns c on t.object_id = c.object_id GROUP BY t.name ORDER BY t.name
Here are the results I ran this query against the Reporting Services database since I didn't have the AdventureWorks readily available.
Here is a look at the Estimated Execution Plans
Here is the Actual Execution Plans
Hopefully you may find this helpful and if you did here is the script... cheers!
Posted by Samson Loo


