How To Find Windows Version Using Registry and SQL Query


We have to run this query from sql server , by connecting each server via query analyzer only

You can also club below query  with given powershell link "Power Shell Script To Read Registry

Note : To find other server details please refer : How To Find Server details using SQL Query from registry

Query:
/*****************************************************************************************/
DECLARE
@key varchar(100),
@CSDVersion varchar (50), -- Latest Patch
@CurrentBuildNumber varchar (100),  -- Windows build
@ProductName varchar (100) -- Windows edition




set @key = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
@key=@key,@value_name='CurrentBuildNumber',
@value=@CurrentBuildNumber
OUTPUT
 
set @key = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
@key=@key,@value_name='CSDVersion',
@value=@CSDVersion
OUTPUT
 
set @key = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
@key=@key,@value_name='ProductName',
@value=@ProductName
OUTPUT
 
SELECT @@ServerName AS [Server Name],
@CurrentBuildNumber as CurrentBuildNumber,
@CSDVersion as CSDVersion ,
@ProductName as ProductName
/*********************************************************************************/
Note : To find other server details please refer : How To Find Server details using SQL Query from registry

No comments:

Post a Comment