SQL Server: Populate all installed instances of MS SQL SERVER

I have Installed several versions of SQL server with different instance names.I needed all the instance names of MS SQL Server installed in My System. I found below script to achieve this
DECLARE @GetAllInstances TABLE
( Value nvarchar(100),
InstanceNames nvarchar(100),
Data nvarchar(100))

Insert into @GetAllInstances
EXECUTE xp_regread
@rootkey = 'HKEY_LOCAL_MACHINE',
@key = 'SOFTWARE\Microsoft\Microsoft SQL Server',
@value_name = 'InstalledInstances'

Select InstanceNames from @GetAllInstances

No comments:

Post a Comment