Little SQL Server Tricks: Get All Views or Tables in Your Database

While cleaning up a project, I needed a list of all the views in the database. SQL Server Management Studio provides a menu for this, but I needed a way to get this data in text form. In SQL Server, you can get this information from the INFORMATION_SCHEMA.TABLES view.

In this view, you get a list of tables and views. If you need only the views, you can filter by TABLE_TYPE = ‘VIEW’:

The list of views in your database

If you only need the tables, you can filter by TABLE_TYPE = ‘BASE TABLE’:

The list of tables in your database

The queries do not look like much, but trust me, they are a great help.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.