当前位置: 代码迷 >> Sql Server >> 用sql语句得到本地ip?解决方法
  详细解决方案

用sql语句得到本地ip?解决方法

热度:22   发布时间:2016-04-27 15:35:12.0
用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 '[email protected]+ ' ' ' ')
select @ip=stuff(str,1,charindex( '[ ',str), ' ')
from ##
where ltrim(str) like 'Pinging% '
select left(@ip,charindex( '] ',@ip)-1)
drop table ##
  相关解决方案