When and how to trace who and when alter the table
2010-07-19 11:35
309 查看
CREATE TABLE TriggerLog (LogInfo xml,HostName Varchar(255), AppName Varchar(255))
create TRIGGER safety
ON DATABASE
FOR DROP_TABLE
AS
DECLARE @EventData AS xml
DECLARE @ObjectName AS VARCHAR(100)
SET @EventData = EVENTDATA() ROLLBACK
INSERT INTO TriggerLog VALUES(@EventData,HOST_NAME(),APP_NAME())
Here is a sample of LogInfo, you can parse it and save it into the table.
<EVENT_INSTANCE>
<EventType>DROP_TABLE</EventType>
<PostTime>2010-07-19T11:30:52.430</PostTime>
<SPID>53</SPID>
<ServerName>FB</ServerName>
<LoginName>FR/ong</LoginName>
<UserName>dbo</UserName>
<DatabaseName>TESTDB</DatabaseName>
<SchemaName>dbo</SchemaName>
<ObjectName>Orders</ObjectName>
<ObjectType>TABLE</ObjectType>
<TSQLCommand>
<SetOptions ANSI_NULLS="ON" ANSI_NULL_DEFAULT="ON" ANSI_PADDING="ON" QUOTED_IDENTIFIER="ON" ENCRYPTED="FALSE" />
<CommandText>DROP TABLE [dbo].[Orders]</CommandText>
</TSQLCommand>
</EVENT_INSTANCE>
create TRIGGER safety
ON DATABASE
FOR DROP_TABLE
AS
DECLARE @EventData AS xml
DECLARE @ObjectName AS VARCHAR(100)
SET @EventData = EVENTDATA() ROLLBACK
INSERT INTO TriggerLog VALUES(@EventData,HOST_NAME(),APP_NAME())
Here is a sample of LogInfo, you can parse it and save it into the table.
<EVENT_INSTANCE>
<EventType>DROP_TABLE</EventType>
<PostTime>2010-07-19T11:30:52.430</PostTime>
<SPID>53</SPID>
<ServerName>FB</ServerName>
<LoginName>FR/ong</LoginName>
<UserName>dbo</UserName>
<DatabaseName>TESTDB</DatabaseName>
<SchemaName>dbo</SchemaName>
<ObjectName>Orders</ObjectName>
<ObjectType>TABLE</ObjectType>
<TSQLCommand>
<SetOptions ANSI_NULLS="ON" ANSI_NULL_DEFAULT="ON" ANSI_PADDING="ON" QUOTED_IDENTIFIER="ON" ENCRYPTED="FALSE" />
<CommandText>DROP TABLE [dbo].[Orders]</CommandText>
</TSQLCommand>
</EVENT_INSTANCE>
相关文章推荐
- How to inspect who is caller of func and who is the class of instance
- How to choose the SIZE and HASHKEYS of hash cluster table?
- how to set up the remote accout who to connection and management mysql server
- How to search a table in a store proc and open the store proc
- C++ How to avoid the enter key when using cin and getline
- 802.11 WDS how does it work, when to use it and what are the limitations
- How to invoke the method of managed bean and render view in JSF when we are outside the lifecycle of JSF
- How can selenium web driver get to know when the new window has opened and then resume its execution
- How To Reclaim Wasted Space on The Segment (Table, Index and LOB) and Tablespace Levels (文档 ID 16827
- use noscript html tag when user disable the javascript in browser, guide user how to enable the js in different browser and retu
- How to adjust the high watermark in ORACLE 10g -- ALTER TABLE SHRINK
- How to solve problem caused when the CRT library and MFC libraries are linked in the wrong order
- How to search a table in a store proc and open the store proc
- How To Reclaim Wasted Space on The Segment (Table, Index and LOB) and Tablespace Levels (文档 ID 16827
- How can the SQL trace and FND Diagnostics be enabled when run a concurrent program?
- How to Create Transportable Tablespaces Where the Source and Destination are ASM-Based
- 需求调研中的5W+1H定律(WHY、WHAT、WHO、WHEN、WHERE + HOW TO ACCOMPLISH THE SYSTEM)
- How to Change the DBID and the DBNAME by using NID [ID 224266.1]
- How to provide username and password when run "git clone git@remote.git"? - Stack Overflow
- How to Monte Carlo Sampling Area Light and What physics quantity is the real percption?