Login or Sign Up to become a member!
LessThanDot Site Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

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: 2.6/5 (46 votes cast)