Monday, March 26, 2012

help on partition

i have a table named table1 sitting on a a partittion scheme px.

table1 is partitioned on u_id by tens,

first partion u_id=0 to 9

second partion u_id=10 to 19

third partion u_id=20 to 29

ans so on and so forth

i have a table named table2 with

records having u_id = 13 to 16

obviously belonging to the second partion.

i want to load table2 to table1 as fast as i could with

the following requirements:

all contents of partition 2 of table1 must be deleted before loading

table2 ceases to exist after the operation

how will i do that.

thanks.

The most efficient way is to do the following:

1. Use ALTER TABLE SWITCH to switch out partition #2 into unpartitioned table (table3)

2. Use ALTER TABLE SWITCH to switch in table2 into partition #2

3. Drop tables table2, table3

The following BOL topic has details on the switching strategies:

http://msdn2.microsoft.com/en-us/library/ms191160.aspx

And please check out the following whitepaper too.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql90/html/sql2k5partition.asp

No comments:

Post a Comment