--获取服务器IP地址CREATE PROCEDURE dbo.sp_GetServerIP ASset xact_abort on
begin
create table #ip(id int identity(1,1),re varchar(2000)) declare @s varchar(1000)
set @s = 'ping ' + host_name() + ' -a -n 1 -l 1'
insert #ip(re) exec master..xp_cmdshell @s select 服务器计算机名 = host_name(),IP地址 = stuff(left(re,charindex(']',re)-1),1,charindex('[',re),'')
from #ip
where id = 2drop table #ip
end
GO
begin
create table #ip(id int identity(1,1),re varchar(2000)) declare @s varchar(1000)
set @s = 'ping ' + host_name() + ' -a -n 1 -l 1'
insert #ip(re) exec master..xp_cmdshell @s select 服务器计算机名 = host_name(),IP地址 = stuff(left(re,charindex(']',re)-1),1,charindex('[',re),'')
from #ip
where id = 2drop table #ip
end
GO
解决方案 »
- 想学C++,求容易懂的教材
- sql server 如何为xml类型节点增加一个属性?
- while循环遍历一个结果集?
- 怎么使变量获取存储过程的返回值?
- 小问题,请大侠帮忙
- 多步OLE DB操作产生错误,错误号-2147217887
- ODBC 连接SQLSERVER创建新数据源
- 求助,如何把.db文件输出成.txt文件?
- Cannot insert explicit value for identity column in table 'iepb02h' when IDENTITY_INSERT is set to OFF.
- 用哪条SQL语句,能在ORACLE里,看到所建的表所在的表空间??
- 请问,在将 varchar 值 '!' 转换成数据类型 int 时失败
- 一条语句是否能实现该功能?高手请进
begin
create table #ip(id int identity(1,1),re varchar(2000)) declare @s varchar(1000)
set @s = 'ping ' + @ComputerName + ' -a -n 1 -l 1'
insert #ip(re) exec master..xp_cmdshell @s select 服务器计算机名 = host_name(),IP地址 = stuff(left(re,charindex(']',re)-1),1,charindex('[',re),'')
from #ip
where id = 2drop table #ip
end
GO