List tables together with the filegroup they reside on

Problem: List tables together with the filegroup they reside on
Solution:

select t.name as ‘table_name’,s.name as ‘schema_name’,f.name as filegroup_name
from sys.indexes i
inner join sys.filegroups f on f.data_space_id = i.data_space_id
inner join sys.tables t on t.object_id=i.object_id
inner join sys.schemas s on s.schema_id = t.schema_id
order by s.name

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: