Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Check which filegroup belong to which partition?

Author  Topic 

ryanlcs
Yak Posting Veteran

62 Posts

Posted - 2010-06-18 : 01:50:40
Is there a way to determine which filegroup belongs to which partition?

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-06-18 : 09:25:31
Try out this query...gives some extra info but it's a script I have laying around so I didn't bother modifying it:
SELECT 
TableName = OBJECT_NAME(i.object_id),
IndexName = i.name,
PartitionNumber = p.partition_number,
FilegroupName = fg.name,
Comparison = CASE boundary_value_on_right WHEN 1 THEN 'less than' ELSE 'less than or equal to' END,
Boundary = CAST(value AS bigint),
[RowCount] = rows,
PartSchemaName = ps.name,
PartFunctionName = f.name
FROM sys.partitions p
JOIN sys.indexes i
ON p.object_id = i.object_id
and p.index_id = i.index_id
JOIN sys.partition_schemes ps
ON ps.data_space_id = i.data_space_id
JOIN sys.partition_functions f
ON f.function_id = ps.function_id
LEFT JOIN sys.partition_range_values rv
ON f.function_id = rv.function_id
AND p.partition_number = rv.boundary_id
JOIN sys.destination_data_spaces dds
ON dds.partition_scheme_id = ps.data_space_id
AND dds.destination_id = p.partition_number
JOIN sys.filegroups fg
ON dds.data_space_id = fg.data_space_id
WHERE i.index_id < 2
ORDER BY partition_number


- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page
   

- Advertisement -