Technical Article

Computer Name from SQL Server

,

Just follow these instructions...!!!

Regards,

Federico Zajur

Q. How can I check the name of the SQL Server I am on? 

A. A SELECT @@SERVERNAME will tell you, but in a cluster you will get the same name back on both machines. If you want the physical server name then use one of the following two methods. 

1. xp_getnetname 

2. declare @computername char (16)

exec master..xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName' 
,'ComputerName',@ComputerName OUTPUT 

select @Computername 

=== 

Applies to SQL Server versions : All
Authors : Federico Zajur

Rate

4.67 (6)

You rated this post out of 5. Change rating

Share

Share

Rate

4.67 (6)

You rated this post out of 5. Change rating