sqlserver2005帮忙写一个触发器,急用
1个回答
展开全部
ip地址的没做过,但是做过记录主机名的,你看看行不行?
CREATE
TRIGGER
tr_ALTER_TABLE
ON
DATABASE
FOR
ALTER_TABLE
AS
begin
DECLARE
@Data
XML
SET
@Data
=
EventData()
INSERT
EvtLog
(PostTime,
LoginName,HostName
EventType,
TSQLCommand)
VALUES
(GETDATE(),
CONVERT(NVARCHAR(100),
system_user),
CONVERT(NVARCHAR(100),
host_name()),
@Data.value('(/EVENT_INSTANCE/EventType)[1]',
'nvarchar(100)'),
@Data.value('(/EVENT_INSTANCE/TSQLCommand)[1]',
'nvarchar(2000)')
)
end
CREATE
TRIGGER
tr_ALTER_TABLE
ON
DATABASE
FOR
ALTER_TABLE
AS
begin
DECLARE
@Data
XML
SET
@Data
=
EventData()
INSERT
EvtLog
(PostTime,
LoginName,HostName
EventType,
TSQLCommand)
VALUES
(GETDATE(),
CONVERT(NVARCHAR(100),
system_user),
CONVERT(NVARCHAR(100),
host_name()),
@Data.value('(/EVENT_INSTANCE/EventType)[1]',
'nvarchar(100)'),
@Data.value('(/EVENT_INSTANCE/TSQLCommand)[1]',
'nvarchar(2000)')
)
end
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询