February 12, 2004 at 11:05 am
Does anyone know how to get the database server's MAC address inside a TransactSql script?
February 12, 2004 at 11:12 am
create table #mac (address varchar(255))
insert into #mac exec xp_cmdshell 'ipconfig.exe /all'
select substring(address, 38, 17) from #mac where address like '%Physical Address%'
drop table #mac
February 12, 2004 at 11:24 am
Thanks!! Thats a start, although I see it requires specific admin roles.
February 12, 2004 at 1:04 pm
The MAC address is stored on the net_address column of the sysprocesses table.
This return the MAC address of the machine running the actual process:
use master
select hostname, MAC=substring(net_address,1,2)+'-'+substring(net_address,3,2)+'-'+substring(net_address,5,2)+'-'+substring(net_address,7,2)+'-'+substring(net_address,9,2)+'-'+substring(net_address,11,2)
from sysprocesses
where spid = @@SPID
February 12, 2004 at 1:06 pm
Very cool, but as you stated, that gets the client's mac address, not the server's. Perhaps I could fish in that same table for processes associated with the server.
February 13, 2004 at 8:23 am
run sysprocesses select as a task, then own spid is running from the server. PS multiple NICs/addresses per server is not uncommon.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy