Search

Monday, February 18, 2013

How many SQL Server Instances are installed on a server?

-- Create Temporary table to store the data

Create Table #SQLInstances
( Value nvarchar(100),
InstanceName nvarchar(100),
Data nvarchar(100))

-- Read Data from Registery

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

Select InstanceName from #SQLInstances

-- Clear the temp table
drop table #SQLInstances

No comments:

Post a Comment