日期:2014-05-18  浏览次数:20410 次

用sql语句得到本地ip?
用什么sql语句可以得到本地的ip啊?

------解决方案--------------------
declare @computerName varchar(20),@ip varchar(20)
set @computerName=host_name()
create table ##(str varchar(100))
exec( 'insert ## exec master..xp_cmdshell ' 'ping '+@computerName+ ' ' ' ')
select @ip=stuff(str,1,charindex( '[ ',str), ' ')
from ##
where ltrim(str) like 'Pinging% '
select left(@ip,charindex( '] ',@ip)-1)
drop table ##