Introduction

Sometimes we may need to get all the tables and views from a database in MS SQL Server. By using T-SQL Statement sp_tables, we can retrieve a list of tables and views.

Syntax

sp_tables [ @table_name = 'Table name.' ] ,
[ @table_owner = 'The database user who created the table.' ] ,
[ @table_qualifier = 'Database name.' ] ,
[ @table_type = "Table, system table, or view." ] ;

The arguments are optional one. Let have a look at the below example,

Example

EXEC sp_tables 

#sql server #sql query #t-sql #sql

Get list of Tables & Views in MS SQL Server
1.15 GEEK