-1

I'm a Junior Programmer But I need help with a query How do I execute a query showing all tables in a Database ??

jarlh
  • 42,561
  • 8
  • 45
  • 63

2 Answers2

1

Please try this. It will give you a list of tables except view.

SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_TYPE = 'BASE TABLE'
Rajan
  • 303
  • 1
  • 12
  • what is information_schema.tables ? and BASE TABLE ? – Eric Sebastian Apr 26 '17 at 01:52
  • Its a view and you can refer this link for more info. https://learn.microsoft.com/en-us/sql/relational-databases/system-information-schema-views/system-information-schema-views-transact-sql – Rajan Apr 26 '17 at 05:16
1

Here is the full name of a table with the schema and table well formatted usable in a query.

SELECT QUOTENAME(TABLE_SCHEMA)+'.'+QUOTENAME(TABLE_NAME)
FROM information_schema.tables
WHERE TABLE_TYPE = 'BASE TABLE'
Hybris95
  • 2,286
  • 2
  • 16
  • 33