Thursday, October 06, 2005

How to find all the tables and views in a database

Use the code below

USE PUBS
GO

--Get All Tables
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
GO

--Get All Views
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'VIEW'
GO

That's all, plain and simple

No comments:

Post a Comment