sql-servert-sqlserverserver-configuration

how to get the system model (product name like :Proliant DL580 Gen9) with SQL Query?


I'm Looking for a way to find the system model like "Proliant DL580 Gen9", but I can't found any way to gain this.

System Model

I try below query and used the "master.sys.xp_regread" procedure to get the server model name

DECLARE @ServerType VARCHAR(max)
EXEC master.sys.xp_regread @rootkey = 'HKEY_LOCAL_MACHINE',
                           @key = 'HARDWARE\DESCRIPTION\System\BIOS\0',
                           @value_name = 'SystemProductName',
                           @value = @ServerType OUTPUT;
SELECT @ServerType 

which returns the NULL value!

Is there a way to get the system model like "Proliant DL580 Gen9"?

Thanks.


Solution

  • Good day,

    You can get the model using the query bellow:

    EXEC master.sys.xp_regread 
        @rootkey = 'HKEY_LOCAL_MACHINE',
        @key = 'HARDWARE\DESCRIPTION\System\BIOS',
        @value_name = 'SystemProductName'
    GO
    

    The result should give you the equivalent information which you get by executing the wmic command

    wmic computersystem get model
    

    For anything that you are not sure, you can simply open the registry using the command regedit, find the value which you are looking for, and change the parameters in the query above

    For example here are some common values which people need:

    EXEC master.sys.xp_regread 
        @rootkey = 'HKEY_LOCAL_MACHINE',
        @key = 'HARDWARE\DESCRIPTION\System\BIOS',
        @value_name = 'SystemManufacturer'
    GO
    EXEC master.sys.xp_regread 
        @rootkey = 'HKEY_LOCAL_MACHINE',
        @key = 'HARDWARE\DESCRIPTION\System\BIOS',
        @value_name = 'SystemVersion'
    GO
    EXEC master.sys.xp_regread 
        @rootkey = 'HKEY_LOCAL_MACHINE',
        @key = 'HARDWARE\DESCRIPTION\System\BIOS',
        @value_name = 'SystemProductName'
    GO
    
    EXEC master.sys.xp_regread 
        @rootkey = 'HKEY_LOCAL_MACHINE',
        @key = 'HARDWARE\DESCRIPTION\System',
        @value_name = 'SystemBiosVersion'
    GO