Created
December 3, 2019 16:33
-
-
Save wbhinton/a25d674474e8f658cd718500b24423fa to your computer and use it in GitHub Desktop.
Get a list of tables and their indices
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
SELECT @@Servername AS ServerName , | |
DB_NAME() AS DB_Name , | |
o.Name AS TableName , | |
i.Name AS IndexName | |
FROM sys.objects o | |
INNER JOIN sys.indexes i ON o.object_id = i.object_id | |
WHERE o.Type = 'U' -- User table | |
AND LEFT(i.Name, 1) <> '_' | |
-- Remove hypothetical indexes | |
ORDER BY o.NAME , | |
i.name; | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment