SqlServer2000有这样的功能吗?

jtg98g3 2005-08-06 02:28:04
在客户端操作数据的时候,能记录客户端的ip地址或者主机名。然后能从历史记录中查到这样的操作记录。
...全文
173 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
iwl 2005-08-20
  • 打赏
  • 举报
回复
coolnick(林息) 的可以
iwl 2005-08-20
  • 打赏
  • 举报
回复
楼上的可以
chinawares 2005-08-18
  • 打赏
  • 举报
回复
楼上的想法有道理,找出系统中的活动主机名,然后逐一ping这么主机名,就可以得到ip,高
coolnick 2005-08-18
  • 打赏
  • 举报
回复
不好意思,上面的有点错误,下面的程序调试通过:

if exists(select name from sysobjects where name='sp_GetClientIp'
and type='P')
drop procedure sp_GetClientIp
go

/*
exec sp_GetClientIp
select * from tableResult
*/

create procedure sp_GetClientIp
as
begin
create table #ip
(
id int identity(1,1),
re varchar(200)
)

if exists(select name from sysobjects where name='tableResult'
and type='U')
begin
drop table tableResult
end

create table tableResult
(
hostName varchar(100),
hostIp varchar(50)
)

declare cur_List cursor for
select hostname from master..sysprocesses

open cur_List

declare @hostName varchar(100),@s varchar(1000)

fetch next from cur_List into @hostName

while (@@fetch_status=0)
begin
if (@hostName='')
begin
fetch next from cur_List into @hostName
continue
end

set @s='ping '+ @hostName +' -n 1 -l 1'
insert #ip(re) exec master..xp_cmdshell @s

insert into tableResult(hostName,hostIp)
select
@hostName,
stuff(left(re,charindex(']',re)-1),1,charindex('[',re),'')
from #ip
where id=2

truncate table #ip

fetch next from cur_List into @hostName
end
close cur_List
deallocate cur_List
end

go
coolnick 2005-08-18
  • 打赏
  • 举报
回复
create procedure sp_GetClientIp
as
begin
create table #ip
(
id int identity(1,1),
re varchar(200)
)

if exists(select name from sysobjects where name='tableResult'
and type='U')
begin
drop table tableResult
end

create table tableResult
(
hostName varchar(100),
hostIp varchar(50)
)

declare cur_List cursor for
select hostname from master..sysprocesses

open cur_List

declare @hostName varchar(100),declare @s varchar(1000)

fetch next from cur_List into @hostName

while (@@fetch_status=0)
begin
set @s='ping '+ @hostName +' -a -n 1 -l 1'
insert #ip(re) exec master..xp_cmdshell @s

insert into tableResult(hostName,hostIp)
select
@hostName,
stuff(left(re,charindex(']',re)-1),1,charindex('[',re),'')
from #ip
where id=2

fetch next from cur_List into @hostName
end
close cur_List
deallocate cur_List
end

go

最后得到的结果表tableResult就包含客户端的ip地址或者主机名



netcoder 2005-08-17
  • 打赏
  • 举报
回复
目前还没有,如果有的话,感觉太消耗资源
AppleBBS 2005-08-17
  • 打赏
  • 举报
回复
程序里写就ok了
jtg98g3 2005-08-08
  • 打赏
  • 举报
回复
服务器没有提供这样的功能吗?

比如能查询到某天的所有对数据库的操作!

ilons1 2005-08-06
  • 打赏
  • 举报
回复
在程序里可以自己把IP当参数传进来,自己做LOG就行了

Andy__Huang 2005-08-06
  • 打赏
  • 举报
回复
得到服务器的IP地址
create table #ip(id int identity(1,1),re varchar(200))
declare @s varchar(1000)
set @s='ping '+left(@@servername,charindex('\',@@servername+'\')-1)+' -a -n 1 -l 1'
insert #ip(re) exec master..xp_cmdshell @s
select 服务器名=@@servername,IP地址=stuff(left(re,charindex(']',re)-1),1,charindex('[',re),'')
from #ip
where id=2

drop table #ip

獲得主機名
select host_name()

27,582

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧