Joseph U.
Joseph U.

Reputation: 4607

SQL Server - Override DELETE command?

I have a situation where I want my Azure MS SQL Server DB Table (or entire DB if needed) to ignore Delete commands it receives from a remote source.

Is there a way to override the delete command default functionality to essentially take the request and send back a success message?

I want to do this so I can have a one way synchronization that keeps deleted records as an archive since the master database that will be sharing the transnational updates will be purged regularly.

Upvotes: 1

Views: 478

Answers (1)

Marc Guillot
Marc Guillot

Reputation: 6455

Yes, there is. You can set a INSTEAD OF DELETE trigger, which replaces the standard actions for DELETE commands with your code (in this case it would be an empty code, so it does nothing when someone tries to delete records from that table).

https://technet.microsoft.com/en-us/library/ms191208(v=sql.105).aspx

Upvotes: 6

Related Questions