admin管理员组文章数量:1516870
create proc sp_get_hostip(@ip varchar(15) output)
AS
declare @cmd varchar(200);
create table #ipTemp(iptext varchar(255));
set @cmd = 'ping -n 1 ' + host_name();
insert #ipTemp exec master..xp_cmdshell @cmd;
select @ip = ISNULL(substring(iptext,(charindex('[',iptext)+1),(charindex(']',iptext)-(charindex('[',iptext)+1))),'') from #ipTemp where charindex('[',iptext)>0;
drop table #ipTemp;
if ( @ip <> '' )
return 1;
else
return 0;
go
--调用
declare @ip varchar(100)
exec sp_get_hostip @ip output
select @ip
版权声明:本文标题:MSSQL新手必学:轻松查看当前服务器IP 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.betaflare.com/biancheng/1771846328a3270130.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论