How to get DOMAIN name from SQL Server?
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)
In T-SQL, you would use this to query the Domain Name of the SQL Server:
SELECT DEFAULT_DOMAIN()[DomainName]