我在数据库上触发了一个触发器,它将停止从我的数据库中删除表,但我只想将它应用于颗粒表而不是所有,为此我想从已删除的触发表中获取表名drop命令执行时插入。我在这里做了一个触发器,请看下面。请帮我完成这项任务我真的需要这个完成。
Create TRIGGER [NO_DROP_Veripda] ON database
for delete
declare @table SYSNAME
select @table= ???? --Here I need help How Can I get table name and insert in this veriable
print @table
IF exists (select sys.sysobjects.name from sys.sysobjects where @table in ('test1','caseflds_bk'))
PRINT 'Dropping tables are not allowed!!!'
else
BEGIN
DISABLE TRIGGER [NO_DROP_Veripda] ON DATABASE
DECLARE @SQL NVARCHAR(MAX)
SELECT @SQL = 'DROP TABLE dbo.' + QUOTENAME(@table) + ''
EXEC sp_executesql @SQL
begin
enable TRIGGER [NO_DROP_Veripda] ON DATABASE
end
END