====== MSSQL Reverse DNS ====== * http://msdn.microsoft.com/de-de/library/ms190693.aspx -- To allow advanced options to be changed. EXEC sp_configure 'show advanced options', 1; GO -- To update the currently configured value for advanced options. RECONFIGURE; GO -- To enable the feature. EXEC sp_configure 'xp_cmdshell', 1; GO -- To update the currently configured value for this feature. RECONFIGURE; GO * http://www.holisticsystems.co.uk/blog/reverse-dns-lookup-ms-sql-server declare @ip_address varchar(16) declare @cmd varchar(100) declare @host_name varchar(100) declare curs cursor LOCAL READ_ONLY --for select ip_address from ip_address_data where arp_domain is null FOR SELECT DISTINCT AwLog.Host FROM AwLog LEFT JOIN DNS ON DNS.Ip = AwLog.Host WHERE DNS.Ip IS NULL open curs create table #output(line nvarchar(100)) while 1=1 begin fetch next from curs into @ip_address if @@fetch_status != 0 break set @cmd = 'nslookup '+@ip_address insert into #output execute xp_cmdshell @cmd --update ip_address_data set --arp_domain = (select substring(line,10,99) from #output where line like 'Name%'), --last_cached = getdate() --where ip_address = @ip_address select @host_name = substring(line,10,99) from #output where line like 'Name%' print(@host_name) INSERT INTO DNS (Ip, HostName) VALUES (@ip_address, @host_name) delete #output end drop table #output close curs