repo.RepoObject__after_delete - TR
type: TR ( trigger ), modify_date: 2021-01-28 20:13:00
RepoObject_guid: 2390291C-9D61-EB11-84DC-A81E8446D5B0
sql_modules_definition
repo.RepoObject__after_delete - TR script
-- =============================================
-- Author: Germo Goertz
-- Create date: 2021-01-01
-- Description: trigger is required because only one updating FK from other tables is possible
-- =============================================
CREATE TRIGGER [repo].[RepoObject__after_delete] ON repo.RepoObject
AFTER DELETE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
--FK would ON DELETE would be better, but FK is defined already for [target_RepoObject_guid]
UPDATE repo.RepoObject_persistence
SET
[source_RepoObject_guid] = NULL
WHERE
[source_RepoObject_guid] IN
(
SELECT
[RepoObject_guid]
FROM
[deleted]
);
END