var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: how to get hostname via SQL command?
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
I haven't tested this, and it requires sysadmin privleges to run, but couldn't you use:
EXECUTE master.dbo.xp_cmdshell 'SET COMPUTERNAME'
this came up on a Google search, so I decided to put up the correct answer.
you can also run:
Check out: SERVERPROPERTY for more info
select SERVERPROPERTY ('ServerName')
SQL server name may be different from hostname just fyi
select HOST_NAME ( ) - This would give the machine name on which the sql server is running.
Please dont try this from Local client it gives PC name of the desktop from which i am using - plz try this inside SQL server of same machine
Actually, that gives you the name of the client from which you have connected.
Originally Posted by rajini_kesavelu