SQL Server – List all Tables in Database

List all Tables in Database.

I want the list of all the user tables in database. How do I get them? Do I have to write a user defined store procedure for it?

Don’t worry, just fire a one line query in T-SQL and you will have list of all the tables in your database.

There two ways to get the list of tables as show in following queries.

USE AdventureWorks

— Method 1

— Display only user tables names in database

SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES

— Display tables properities also

SELECT * FROM INFORMATION_SCHEMA.TABLES

— Method 2

— Display only user tables names in database

SELECT name FROM sysobjects WHERE TYPE = ‘U’

— Display tables properities also

SELECT * FROM sysobjects WHERE TYPE = ‘U’

Good Luck!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: