Created
December 3, 2019 16:20
-
-
Save wbhinton/2e43d020a4fc3ca911e39dc86b356a68 to your computer and use it in GitHub Desktop.
List all tables in a database with descriptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EXEC sp_tables; | |
-- Note this method returns both table and views. | |
--OR | |
SELECT @@Servername AS ServerName , | |
TABLE_CATALOG , | |
TABLE_SCHEMA , | |
TABLE_NAME | |
FROM INFORMATION_SCHEMA.TABLES | |
WHERE TABLE_TYPE = 'BASE TABLE' | |
ORDER BY TABLE_NAME | |
; | |
--OR | |
SELECT @@Servername AS ServerName , | |
DB_NAME() AS DBName , | |
o.name AS 'TableName' , | |
o.[Type] , | |
o.create_date | |
FROM sys.objects o | |
WHERE o.Type = 'U' | |
-- User table | |
ORDER BY o.name; | |
--OR | |
SELECT @@Servername AS ServerName , | |
DB_NAME() AS DBName , | |
t.Name AS TableName, | |
t.[Type], | |
t.create_date | |
FROM sys.tables t | |
ORDER BY t.Name; | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment