sql 此SQL查询用于通过计算机集合的公司信息获取BIOS和硬件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 此SQL查询用于通过计算机集合的公司信息获取BIOS和硬件相关的知识,希望对你有一定的参考价值。

/*
*********************************************************************************************************
* Requires          | SQL, company AD attribute, Wi32_Computer_System_Product WMI class gathering       *
* ===================================================================================================== *
* Modified by       |    Date    | Revision | Comments                                                  *
* _____________________________________________________________________________________________________ *
* Octavian Cordos   | 2018-01-18 | v1.0     | First version                                             *
* Ioan Popovici     | 2018-08-08 | v1.1     | Added localizations, sorting, template, element naming    *
* Ioan Popovici     | 2018-08-21 | v1.2     | Fixed duplicates minor formating fixes                    *
* Ioan Popovici     | 2018-08-23 | v1.3     | Removed company query                                     *
* ===================================================================================================== *
*                                                                                                       *
*********************************************************************************************************

.SYNOPSIS
    This SQL Query is used to get the Hardware info of a Computer Collection.
.DESCRIPTION
    This SQL Query is used to get the Hardware info of a Computer Collection including BIOS version and Computer model.
.NOTES
    Part of a report should not be run separately.
.LINK
    https://sccm-zone.com
    https://github.com/JhonnyTerminus/SCCM
*/

/*##=============================================*/
/*## QUERY BODY                                  */
/*##=============================================*/

SELECT DISTINCT

    /* IMPORTANT! YOU NEED TO ENABLE THE COMPANY FIELD GATHERING FOR SYSTEM DISCOVERY OTHERWISE THIS COLUMN IS NOT AVAILABLE */
    System.Company0 as 'Company',

    /* CUSTOM FUNCTION LEAVE DISABLED */
    --( SELECT [CM_Tools].[dbo].[ufn_GetCompany_by_ResourceID]([System].[ResourceID]) ) AS [Company],

    System.Manufacturer0 AS Manufacturer,
    CASE
        WHEN System.Model0 LIKE '10AA%' THEN 'ThinkCentre M93p'
        WHEN System.Model0 LIKE '10AB%' THEN 'ThinkCentre M93p'
        WHEN System.Model0 LIKE '10AE%' THEN 'ThinkCentre M93z'
        WHEN System.Model0 LIKE '10FLS1TJ%' THEN 'ThinkCentre M900'
        WHEN Product.Version0 = 'Lenovo Product' THEN ('Unknown ' + System.Model0)
        WHEN System.Manufacturer0 = 'LENOVO' THEN Product.Version0
        ELSE System.Model0
    END AS Model,
    System.Name0 AS DeviceName,
    System.UserName0 AS UserName,
    BIOS.Name0 AS BIOSName,
    BIOS.Version0 AS BIOSVersion,
    BIOS.SMBIOSBIOSVersion0 AS SMBIOSVersion,
    BIOS.SerialNumber0 AS BIOSSerialNumber,
    OperatingSystem.Caption0 AS OperatingSystem,
    OperatingSystem.CSDVersion0 AS OSServicePack,
    OperatingSystem.Version0 AS OSBuildNumber,
    OperatingSystem.InstallDate0 AS OSInstallDate,
    OSLocalizedNames.Value AS OSVersion
FROM dbo.fn_rbac_GS_COMPUTER_SYSTEM(@UserSIDs) AS System
    JOIN dbo.v_GS_OPERATING_SYSTEM OperatingSystem ON OperatingSystem.ResourceID = System.ResourceID
    LEFT JOIN dbo.vSMS_WindowsServicingStates AS OSServicingStates ON OSServicingStates.Build = OperatingSystem.Version0
    LEFT JOIN vSMS_WindowsServicingLocalizedNames AS OSLocalizedNames ON OSLocalizedNames.Name = OSServicingStates.Name
    JOIN dbo.v_ClientCollectionMembers AS Collections ON Collections.ResourceID = System.ResourceID
    JOIN dbo.v_GS_PC_BIOS BIOS ON BIOS.ResourceID = System.ResourceID
    JOIN dbo.v_GS_COMPUTER_SYSTEM_PRODUCT AS Product ON Product.ResourceID = System.ResourceID
WHERE Collections.CollectionID = @CollectionID
    AND
        System.Model0 NOT LIKE (
            CASE @ExcludeVirtualMachines
                WHEN 'YES' THEN '%Virtual%'
                ELSE ''
            END
        )
ORDER BY
    Model,
    BIOSName,
    BIOSVersion

/*##=============================================*/
/*## END QUERY BODY                              */
/*##=============================================*/

以上是关于sql 此SQL查询用于通过计算机集合的公司信息获取BIOS和硬件的主要内容,如果未能解决你的问题,请参考以下文章

sql 通过计算机集合的制造商信息获取BIOS和硬件信息。

用于计算“保留”库存项目的 SQL 查询

用于检查房间可用性的 SQL 查询

sql语句分组/排序/计算总数/连接等sql语句书写

BigQuery SQL语法错误FOR函数(“语法错误:预期的”)”,但在[7:18]处获得了关键字FOR)

SQL Server:通过查询找出列的默认值