Question

I tried using EXEC sp_who2; to find the server's domain name, but it gives host, users, etc.

I need to know my SQL Server's domain name, so I can install a plugin to the SQL Server Management Studio.

Was it helpful?

Solution

In T-SQL, you would use this to query the Domain Name of the SQL Server:

SELECT DEFAULT_DOMAIN()[DomainName]

OTHER TIPS

Get your FQDN like so:

DECLARE @Domain varchar(100), @key varchar(100)
SET @key = 'SYSTEM\ControlSet001\Services\Tcpip\Parameters\'
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', @key=@key,@value_name='Domain',@value=@Domain OUTPUT 
SELECT 'Server Name: '+@@servername + ' Domain Name:'+convert(varchar(100),@Domain)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top