Archive for August, 2012

List tables together with the filegroup they reside on

August 21, 2012

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