SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On



Truncate Table Partition command Expand / Collapse
Author
Message
Posted Thursday, February 04, 2010 5:41 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Yesterday @ 12:21 PM
Points: 706, Visits: 112
Comments posted to this topic are about the item Truncate Table Partition command


Post #860065
Posted Thursday, February 18, 2010 1:03 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, March 17, 2010 5:51 PM
Points: 300, Visits: 157
I dont know if i am wrong but is there a easy way out for this.

May be if i say.

Partition function fx(10,20,30)
partition scheme sc on fx all to primary
Create Table blabla_bla ( i int primary Key scheme fx(i))on fx(i)

create table blabla_bla_mirror( i int primary Key scheme fx(i))on fx(i))

switch partiton x to blabla_bla_mirror (x)

your partition is empty now

drop table mirror.


Regards
Vinay
Post #868453
Posted Saturday, February 20, 2010 10:27 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Yesterday @ 12:21 PM
Points: 706, Visits: 112
Hi Vinay,

Yes,
For truncating partition you need to create the mirror/dummy table with similar schema and on same file group where the partition is residing; and then use the Alter tables switch statement.

Dont you think that considerable manual work is involved here?
This procedure automates the all the steps involved. You dont need to know about schema of the table, file group of the partition etc, you do not need to create and drop the dummy tables etc.

Also if you are migrating some code/database from Oracle to SQL Server where ALTER TABLE ..TRUNCATE PARTITION command is used, you can replace such statement by adding call to this procedure here.

Regards,
Vidhyadhar



Post #869677
Posted Saturday, February 20, 2010 10:29 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Yesterday @ 12:21 PM
Points: 706, Visits: 112
One more thing is this procedure takes care if the partition is compressed. One more manual step is eliminated.
If you are doing it manually you need to find out compression type of Partition and Mirror/Dummy table should have same Compression.

Regards,
Vidhaydhar



Post #869679
Posted Wednesday, March 17, 2010 3:41 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, March 17, 2010 3:36 AM
Points: 1, Visits: 2
Hello,

if i have a table containing an auto increment unique id, this table is partitioned based on date time field.

what happens to the auto increment values when i truncate a partition?

Will the partitions that are still available inherit the truncated id's or will the id continue incrementing as if nothing happened?

Post #884485
Posted Wednesday, March 17, 2010 9:05 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Yesterday @ 12:21 PM
Points: 706, Visits: 112
Yes second option is correct. it will keep on incrementing from the last IDENTITY value.


Post #884772
« Prev Topic | Next Topic »


Permissions Expand / Collapse