How to find all the tables and views in a database
From Wiki
It is actually quite simple to list all the tables and/or views in your database, you can use the ANSI standars INFORMATION_SCHEMA.TABLE view. Here is what the query looks like
- USE PUBS
- GO
- --Get All Tables
- SELECT *
- FROM INFORMATION_SCHEMA.TABLES
- WHERE TABLE_TYPE = 'BASE TABLE'
- GO
- --Get All Views
- SELECT *
- FROM INFORMATION_SCHEMA.TABLES
- WHERE TABLE_TYPE = 'VIEW'
- GO
Contributed by: --SQLDenis 17:11, 7 June 2008 (GMT)
Part of SQL Server Admin Hacks


