1

I am using SQL Server 2014 and want to get all the tables name in a particular database STUDENT through a SQL query.

How is it possible?

Thanks

0

1 Answer 1

5

You want to query sys.objects and look for everything with the type description 'USER_TABLE'. You could use a query like this;

SELECT 
*
FROM STUDENT.sys.objects
WHERE type_desc = 'USER_TABLE'

The FROM clause has the usual format: DatabaseName.SchemaName.TableName.

Or as marc_s mentions, you can use sys.tables instead;

SELECT 
*
FROM STUDENT.sys.tables
Sign up to request clarification or add additional context in comments.

10 Comments

Or you could just use the more focused sys.tables catalog view and not have to deal with the type_desc anymore....
@Rich benner my database name is STUDENT and i want to get the names of all tables only exist into the STUDENT database, so how can i use above query according to my database
That doesn't make sense. You want the names of all of the tables within another table?
@Rich Benner Sorry my mistake actually STUDENT is my database name
Yes, so your database 'STUDENT' contains a number of tables. The query above will list all tables that exist within your database. I don't understand the complication here.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.