Sunday, February 19, 2012

how to get hostname via SQL command?

Hi!
Can something tell me how I can obtain the machine name (either IP address or DNS name) on which SQL Server is running via a SQL query?
select @.@.version returns a lot of useful information, however it doesn't return the host name.
thanks in advance
- GarryI haven't tested this, and it requires sysadmin privleges to run, but couldn't you use:EXECUTE master.dbo.xp_cmdshell 'SET COMPUTERNAME'-PatP

No comments:

Post a Comment