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
 General SQL Server Forums
 New to SQL Server Programming
 sugestion needed

Author  Topic 

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2008-06-06 : 06:27:44
Hi



We need to have a mass delete from a table A after some process execution and that deleted data is to be archived into a table B before the deletion. We would like to know which one would be faster in SQL server –



1) A trigger on delete upon table A

2) Copy data from table A to table B based upon deletion conditions and then delete from table A



Any other alternative suggestions are also welcome.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-06 : 06:28:28
I think option 2 will be better.
Go to Top of Page

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2008-06-06 : 06:30:21
dear friend,please tell me why
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-06 : 06:31:27
See http://weblogs.sqlteam.com/peterl/archive/2007/10/03/New-OUTPUT-operator.aspx for more information
DELETE     a
OUTPUT 10 * deleted.i + 49
INTO #TableB
FROM #TableA AS a
WHERE i = 2



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2008-06-06 : 06:35:01
thank u peso
Go to Top of Page
   

- Advertisement -