Login or Sign Up to become a member!

EXPERTS, INFORMATION, IDEAS & KNOWLEDGE

Social bookmarker Add this

How to find all the tables and views in a database

From Wiki

Jump to: navigation, search

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

  1. USE PUBS
  2. GO
  3.  
  4. --Get All Tables
  5. SELECT *
  6. FROM INFORMATION_SCHEMA.TABLES
  7. WHERE TABLE_TYPE = 'BASE TABLE'
  8. GO
  9.  
  10. --Get All Views
  11. SELECT *
  12. FROM INFORMATION_SCHEMA.TABLES
  13. WHERE TABLE_TYPE = 'VIEW'
  14. GO



Contributed by: --SQLDenis 17:11, 7 June 2008 (GMT)


Part of SQL Server Admin Hacks

361 Rating: 0.0/5 (0 votes cast)