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 2008 Forums
 Transact-SQL (2008)
 partition table

Author  Topic 

noamg
Posting Yak Master

215 Posts

Posted - 2009-09-02 : 03:19:12
I have a partition table, with few filegroups.
how to know into which filegroup SQL write the new row ?


Noam Graizer

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-09-02 : 04:22:01
It depends on the definition of your Partition Function. And you can use this query to check:
SELECT $PARTITION.MYPARTITIONFUNCTION(100) [PARTITION NUMBER]

Lookup $PARTITION in BOL
Go to Top of Page

noamg
Posting Yak Master

215 Posts

Posted - 2009-09-02 : 04:43:24
I ask into which FILEGROUP the row will be inserted !?

Noam Graizer
Go to Top of Page

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-09-02 : 10:06:24
$PARTITION will give you the partition id and this query will give the associated filegroup:

select ds.name AS [Filegroup Name], destination_id AS [partition number]
from sys.data_spaces ds
inner join sys.destination_data_spaces dds on (ds.data_space_id = dds.data_space_id)
inner join sys.partition_schemes ps on (ps.data_space_id = dds.partition_scheme_id)
order by ds.name ASC

Have a look at the other partition related catalog views in BOL.
Go to Top of Page
   

- Advertisement -