T-SQL Count of Tables, Views, Stored Procedures and Functions

Posted by: Jason N. Gaylords Blog, on 29 Oct 2013 | View original | Bookmarked: 0 time(s)

Have you ever needed to obtain a list or count of all tables, views, stored procedures, and functions in a database? Its quite easy. Simply copy the T-SQL from below to a query window, set the desired database and execute.

SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'
SELECT * FROM INFORMATION_SCHEMA.VIEWS
SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE'
SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'FUNCTION'

This will produce four result sets that will list the tables, views, stored procedures and functions. You can simply update the select statements with the keyword count to grab the count of each object if thats all you are looking for.

Category: XSD | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1436 | Hits: 9

Similar Posts

  • Connecting to SQL Azure with Telerik OpenAccess more
  • SQL Server Compact Edition 3.5 more
  • GURA - Paradigm Shift in Object Relational Mapping more
  • Foundations of Programming - Part 6 - NHibernate more
  • SqlNetFramework an easier alternative to microsoft data application block more
  • LINQ, LINQ To SQL, LINQ To XML, Entity Framework course out now more
  • How to debug a stored procedure in your Sql Server 2005 more
  • How can I Install Membership, Roles and Profile on my Hosted Site? more
  • Examining ASP.NET 2.0's Membership, Roles, and Profile - Part 9 more
  • The SQL Data Tools in Orcas more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD