在触发器中如何获取客户端地址

在触发器中可以记录下删除前后的数据,但是,怎么样才能知道删除的命令来自哪个客户端(IP地址)?
---------------------------------------------------------------

--改改:

create table #ip(id int identity(1,1),re varchar(200))

declare @s varchar(1000)
set @s='ping '+host_name()+' -a -n 1 -l 1'
insert #ip(re) exec master..xp_cmdshell @s

select 客户端计算机名=host_name(),IP地址=stuff(left(re,charindex(']',re)-1),1,charindex('[',re),'')
from #ip
where id=2

drop table #ip

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus