sql server 獲取本機的ip位址

2021-08-26 19:33:01 字數 954 閱讀 5905

--sql server 獲取本機的ip位址

-- 其實就是使用xp_cmdshell 來獲取資訊,然後對資訊進行篩選。

--開啟xp_cmdshell exec sp_configure 'show advanced options', 1 reconfigure with override exec sp_configure 'xp_cmdshell', 1 reconfigure with override exec sp_configure 'show advanced options', 0 reconfigure with override go begin declare @ipline varchar(200) declare @pos int declare @ip varchar(40) set nocount on set @ip = null if object_id('tempdb..#temp') is not null drop table #temp create table #temp (ipline varchar(200)) insert #temp exec master..xp_cmdshell 'ipconfig' select @ipline = ipline from #temp where upper (ipline) like '%ipv4 位址%'--這裡需要注意一下,系統不同這裡的匹配值就不同 if @ipline is not null begin set @pos = charindex (':',@ipline,1); set @ip = rtrim(ltrim(substring (@ipline , @pos + 1 , len (@ipline) - @pos))) end select distinct(rtrim(ltrim(substring (@ipline , @pos + 1 , len (@ipline) - @pos)))) as ipaddress from #temp drop table #temp set nocount off end go

獲取本機SqlServer名稱

using system.data.sql 檢索包含有關可用sql server例項的資訊的表,必須先使用共享 靜態instance屬性來檢索列舉器 sqldatasourceenumerator instance sqldatasourceenumerator.instance 呼叫 getdat...

golang本地監聽埠獲取本機網絡卡的IP和MAC

主要的思路就是 1 使用http暴露介面 2 使用net包讀取本地的ip和mac 主要的 如下 獲取本機ip func getlocalip string for address range addrs return 獲取本機mac func getmac string for inter rang...

獲取本機的位址

剛學網路程式設計,試著做了乙個獲取本機的名及位址的方法,開始怎麼也獲取的不對,原來錯誤在這裡 i longint pointer p h addr list 這句開始少了 pointer 了,因為 h addr list 本來就是乙個指標 pchar,所以取得了這個指標的值後再去獲取這個指標所指向的...