I must make a trigger that does not allow to alter tables that are registered within a specific table.
For this, what I was thinking is to make an IF that asks if the name of the base, the schema and the name of the table are housed in that table.
Here's part of the code:
IF @DB IN (SELECT [DB] FROM Management.deployer.CriticalTables)
AND @SCHEMA IN (SELECT [SCHEMA] FROM Management.deployer.CriticalTables)
AND @NAME IN (SELECT [NAME] FROM Management.deployer.CriticalTables)
(The variables are all declared) The question is that for example, if inside the table I have:
BD: schema: tabla:
manag TM prueba
manag TM prueba2
manag TD prueba
When modifying the first table (manag.TM.test), the trigger does not jump and the table is modified.
Any solution?
PS: I also tried the following
IF @DB IN (SELECT [DB] FROM Management.deployer.CriticalTables)
BEGIN
IF @SCHEMA IN (SELECT [SCHEMA] FROM Management.deployer.CriticalTables)
BEGIN
IF @NAME IN (SELECT [NAME] FROM Management.deployer.CriticalTables)
BEGIN
PRINT 'ERROR'
END
END
END