martedì 19 febbraio 2013

Getting SQL Server IP Address


If you need to know the IP of your SQL Server, the seguent scripts is what you need:


declare @cmdresults as table(ip varchar(255))
insert into @cmdresults exec xp_cmdshell'ipconfig | find "IPv4"'
select ltrim(rtrim(substring(ip,charindex(':',ip)+1,len(ip)))) from @cmdresults where ip is not null  

or


declare @cmdresults as table(ip varchar(255))
insert into @cmdresults exec xp_cmdshell'ipconfig | find "IP Address"'
select ltrim(rtrim(substring(ip,charindex(':',ip)+1,len(ip)))) from @cmdresults where ip is not null  

My Two Cents ... 

Nessun commento:

Posta un commento