Article

Get the list of all Tables, Views, Stored procedures with in a database in SQL Server

30 May 2018 Alok Kushwaha
0 Comments 137 Views



many times we need to get the list of Tables, Views, Stored procedures with in a database to perform some actions. Today we explain all the ways to extraxt the list of objects like table, views and stored procedures.

Different Way to get stored procedure list from the database

SELECT * FROM sys.procedures

SELECT * FROM sys.objects WHERE [type] = 'P'

SELECT * FROM sys.all_objects WHERE [Type] = 'P' AND is_ms_shipped = 0 -- Exclude system procedures

SELECT * FROM sysobjects WHERE [XType] = 'P'

Different Way to get table list from the database

SELECT * FROM sys.tables

SELECT * FROM sys.objects WHERE [Type] = 'U'

SELECT * FROM sys.all_objects WHERE [Type] = 'U' AND is_ms_shipped = 0 -- Exclude system tables

SELECT * FROM sysobjects WHERE [XType] = 'U'

SELECT * FROM INFORMATION_SCHEMA.TABLES

Different Way to get view list from the database

SELECT * FROM sys.views

SELECT * FROM sys.objects WHERE [Type] = 'V'

SELECT * FROM sys.all_objects WHERE [Type] = 'V' and is_ms_shipped = 0 -- Exclude system views

SELECT * FROM sysobjects WHERE [XType] = 'V'

SELECT * FROM  INFORMATION_SCHEMA.VIEWS

 

Comments

No coments found to display!

Leave a Comment