我正在调试一些问题,怀疑是在我们使用sp_rename重命名某些表的错误代码的地方。
为了证明这一点,我创建了一个DDL触发器
Create Trigger ddlTrigger_LogAlterTable
On Database For ALTER_TABLE
As
Insert Into DropTableCommandLogs (
EventType,
PostTime,
LoginName,
UserName,
DatabaseName,
SchemaName,
ObjectName,
ObjectType,
CommandText
)
Select
EventType = EVENTDATA().value('(EVENT_INSTANCE/EventType)[1]', 'sysname'),
PostTime = EVENTDATA().value('(EVENT_INSTANCE/PostTime)[1]', 'datetime'),
LoginName = EVENTDATA().value('(EVENT_INSTANCE/LoginName)[1]', 'sysname'),
UserName = EVENTDATA().value('(EVENT_INSTANCE/UserName)[1]', 'sysname'),
DatabaseName = EVENTDATA().value('(EVENT_INSTANCE/DatabaseName)[1]', 'sysname'),
SchemaName = EVENTDATA().value('(EVENT_INSTANCE/SchemaName)[1]', 'sysname'),
ObjectName = EVENTDATA().value('(EVENT_INSTANCE/ObjectName)[1]', 'sysname'),
ObjectType = EVENTDATA().value('(EVENT_INSTANCE/ObjectType)[1]', 'sysname'),
CommandText = EVENTDATA().value('(EVENT_INSTANCE//TSQLCommand[1]/CommandText)[1]', 'nvarchar(max)')
GO
但是,当我运行sp_rename'dog','cat'时,在日志表中什么都看不到。我在做什么错了?