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 2000 Forums
 Transact-SQL (2000)
 Are triggers executed on restore?

Author  Topic 

Ken Blum
Constraint Violating Yak Guru

383 Posts

Posted - 2004-04-26 : 23:54:15
If a recover a database backup, are table triggers re-executed? What about when restoring transactional backups?

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-27 : 00:08:53
They would be in both cases. I'm curious why you are asking though. :)

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2004-04-27 : 00:30:12
What?????

I hope not!!! AFAIK a restore is considered a physical process outside the scope of the TSQL execution engine and hence would not fire any triggers defined on any table...




DavidM

"If you are not my family or friend, then I will discriminate against you"
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-27 : 01:45:42
hmmmm, I should probably explain my reply, huh. lol

When you recover a database, any transactions that took place because of triggers will be reflected in the restore. The triggers don't need to "re-execute" per se. The actions of the past are part of the restore so there is nothing to re-execute.

Does that make sense? They are re-executed in that the changes are reflected in the restore. There is not an actual physical re-execution.

Sorry about that byrmol. I shouldn't post at midnight. lol

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

Ken Blum
Constraint Violating Yak Guru

383 Posts

Posted - 2004-04-27 : 09:14:44
OK, so the answer is no correct?

The reason I am asking is that I have an Insert trigger on a database table that inserts records into another database table. So, if the restore of the source database does not execute the triggers then the records will not be re-inserted into the secondary database. Are we sure this also does not happen when restoring a transactional backup?

Thanks
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-27 : 10:34:12
You would have to restore the other database as well. Any databases that are interrelated should be on the same transaction log backup schedule so you can keep data in sync and not have a nightmare restore scenario.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -