Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Linked Server returns only one row while reading remote server registry

$
0
0

The below script is to read registry information using linked server, however it returns only one row instead of multiple rows.

SELECT a.* FROM OPENQUERY(LinkedServerName,
  'SET FMTONLY OFF; Exec ('' Use [master]; 
  DECLARE @RootKey VARCHAR(30), @InstanceName VARCHAR(100), @Key VARCHAR(200)
  DECLARE @StartupParams VARCHAR(100), @InstanceVersion VARCHAR(50), @InstanceValue VARCHAR(200)
       SELECT @InstanceVersion = @@serviceName
  --SELECT @InstanceVersion
  EXEC master.dbo.xp_instance_regread ''''HKEY_LOCAL_MACHINE'''',
  ''''SOFTWARE\MICROSOFT\\Microsoft SQL Server\\Instance Names\\SQL'''', @InstanceVersion, @InstanceValue OUTPUT
  SELECT @InstanceName = @InstanceValue
  --SELECT @InstanceName
  SET @RootKey = ''''HKEY_LOCAL_MACHINE''''
  SET @Key = ''''SOFTWARE\Microsoft\\Microsoft SQL Server\'''' + @InstanceName + ''''\MSSQLServer\Parameters''''
  exec master..xp_regenumvalues @RootKey, @Key
  '')') a


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>