by
0
6
2,700
0
Top 1% !
Popular
Famous
Tagged
Refined
OpenSource
Popularity: 5596th place
Architecturex86_64
BrowserAll
DBMSMS SQL Server
LanguageSQL
LicenseMIT_X11
OSWindows

How to Retrieve all the tables having indexes on a specific filegroup in SQL Server

Here are listed all the tables that have one or more indexes stored in a filegroup called 'INDEXES'
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/206183/How-to-Retrieve-all-the-tables-having-in?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
SELECT distinct TableName = t.name FROM sys.indexes ind INNER JOIN sys.index_columns ic ON ind.object_id = ic.object_id and ind.index_id = ic.index_id INNER JOIN sys.columns col ON ic.object_id = col.object_id and ic.column_id = col.column_id INNER JOIN sys.tables t ON ind.object_id = t.object_id INNER JOIN sys.[filegroups] f ON f.[data_space_id] = ind.data_space_id WHERE f.name = 'INDEXES'
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus