怎么样识别一台主机上运行的是SQL SERVER 服务呢?,我想 SQL SERVER 默认的是1433端口,(可惜这个端口是可以任意改变的,只要不和系统端口冲突),假设端口没被改过,那么还有可能通过socket监听端口,看对方有没回应来取得主机器的ip或是机器名.但是要端口改掉了,我就不知道怎么办了.
2,或者
declare @cmdStr varchar(100)
create table #table(id int identity,txt varchar(1000))
create table #t(hostname varchar(100), ip varchar(100))
declare @id int
declare @hostname varchar(100)
set @id = 50
set nocount on
while exists (select top 1 HostName from master..sysprocesses where spid > @id)
begin
select top 1 @cmdStr='ping '+HostName, @id = spid, @hostname = hostname from master..sysprocesses where spid > @id order by spid
insert into #table(txt) exec master..xp_cmdshell @cmdStr
insert #T select @hostname, substring(txt,charindex('[',txt)+1,charindex(']',txt)-charindex('[',txt)-1) from #table where id=2
truncate table #table
end
set nocount off
select distinct * from #t
drop table #table
drop table #t