登录名) SELECT @ EventData.value('(/ EVENT_INSTANCE / EventType)[1]','NVARCHAR(100)') , @ EventData.value('(/ EVENT_INSTANCE / TSQLCommand)[1]', 'NVARCHAR(MAX)') , @EventData, @ EventData.value('(/ EVENT_INSTANCE / SchemaName)[1]', 'NVARCHAR(255)'), @ EventData.value('(/ EVENT_INSTANCE / ObjectName)[1]','NVARCHAR(255)' ), Db_name (), Host_name(), @ip, Program_name(), Suser_sname(); END 解决方案 没有。它不会插入任何记录,因为它不会被DML语句触发。 这是一个scema审计触发器(数据库触发器),由以下事件触发: CREATE_PROCEDURE,ALTER_PROCEDURE,DROP_PROCEDURE,CREATE_TABLE,ALTER_TABLE,DROP_TABLE,CREATE_FUNCTION,ALTER_FUNCTION,DROP_FUNCTION ,CREATE_VIEW,ALTER_VIEW,DROP_VIEW,CREATE_TRIGGER,ALTER_TRIGGER 咨询 MSDN [ ^ ]。 create TRIGGER [AuditDB_Trigger]ON DATABASEFOR create_procedure, alter_procedure, drop_procedure,CREATE_Table, ALTER_Table, DROP_Table,CREATE_Function, ALTER_Function, DROP_Function,CREATE_View, ALTER_View, DROP_View,CREATE_TRIGGER,ALTER_TRIGGERAS BEGIN SET nocount ON; DECLARE @EventData XML = Eventdata(), @ip VARCHAR(32); SELECT @ip = client_net_address FROM sys.dm_exec_connections WHERE session_id = @@SPID; INSERT AuditDB.dbo.DDLEvents (eventtype, eventddl, EventXML, schemaname, objectname, databasename, hostname, ipaddress, programname, loginname) SELECT @EventData.value('(/EVENT_INSTANCE/EventType)[1]', 'NVARCHAR(100)') , @EventData.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'NVARCHAR(MAX)') , @EventData, @EventData.value('(/EVENT_INSTANCE/SchemaName)[1]', 'NVARCHAR(255)'), @EventData.value('(/EVENT_INSTANCE/ObjectName)[1]', 'NVARCHAR(255)' ), Db_name(), Host_name(), @ip, Program_name(), Suser_sname(); END 解决方案 No. It will insert no record as it is not fired by DML statements. This is a scema audit trigger (a database trigger), which is fired by these events: CREATE_PROCEDURE, ALTER_PROCEDURE, DROP_PROCEDURE,CREATE_TABLE, ALTER_TABLE, DROP_TABLE,CREATE_FUNCTION, ALTER_FUNCTION, DROP_FUNCTION,CREATE_VIEW, ALTER_VIEW, DROP_VIEW,CREATE_TRIGGER,ALTER_TRIGGERConsult MSDN[^]. 这篇关于当我们在Button上创建表时,触发器插入两行单击ExecuteNonQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 11-02 04:22