Page 1 of 1

Truncating a table with a condition

Posted: Tue May 08, 2007 1:10 am
by purush
Hi,

I need to truncate a table based on a conditon.........For a column 'Input' There will be two values A and B. I need to truncate only for the value A.

Previously when there was no condition I used to use Stored Procedrue to truncate the entire table.........Now can I use SP with a condition to truncate the table.......

Please suggest me an :idea:

Thanks in Advance.......
Purush

Posted: Tue May 08, 2007 3:00 am
by nick.bond
what database are you using?

you can't truncate with a condition, that would be performing a delete.

If you partition your table by the column in question you could drop the partition which will probably be quicker that a delete if you have a huge table.

Posted: Tue May 08, 2007 5:01 am
by chulett
Can you approach this as a series of discrete steps? Evaluate your condition, possibly truncate, etc - all controlled in a Sequence job by triggers?

Posted: Tue May 08, 2007 4:46 pm
by ray.wurlod
Is the question IF condition THEN truncate ELSE don't or is the question truncate only certain rows?