2010-05-12 4 views

Répondre

0

Pour obtenir Sql Server instance est

Declare @key Varchar(100), @PortNumber varchar(20) 

if charindex('\',CONVERT(char(20), SERVERPROPERTY('servername')),0) <>0 

begin 

set @key = 'SOFTWARE\MICROSOFT\Microsoft SQL Server\'[email protected]@servicename+'\MSSQLServer\Supersocketnetlib\TCP' 

end 

else 

begin 

set @key = 'SOFTWARE\MICROSOFT\MSSQLServer\MSSQLServer\Supersocketnetlib\TCP' 

end 

EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', @[email protected],@value_name='Tcpport',@[email protected] OUTPUT 

SELECT CONVERT(char(20), SERVERPROPERTY('servername')) ServerName, 

CONVERT(char(20), SERVERPROPERTY('InstanceName')) instancename 

OU

SELECT SERVERPROPERTY('InstanceName') 
Questions connexes