Symantec Management Platform (Notification Server)

 View Only
  • 1.  Sql query to convert ram from bytes to gb?

    Posted Apr 08, 2016 10:49 AM

    I am querying sql to get hardware inventory and got the physical memory but its in bytes.  How do i convert it to GB or is there another table i can use?  I can currently using:

    ics.[Total Physical Memory (Bytes)]

     

    Thanks!



  • 2.  RE: Sql query to convert ram from bytes to gb?

    Posted Apr 08, 2016 11:11 AM

    I've used the following:

    SELECT
      ...
      hwcs.[Total Physical Memory (Bytes)],
      round(hwcs.[Total Physical Memory (Bytes)]/1073741824*100000,0)/100000 [RAM GB],
      ...
    FROM
      ...
      LEFT JOIN Inv_HW_Computer_System hwcs ON hwcs._ResourceGuid = a.[Guid]
    

     



  • 3.  RE: Sql query to convert ram from bytes to gb?

    Broadcom Employee
    Posted Apr 08, 2016 11:19 AM

    Hi baldiesrt,

    here is a short example of how you can convert bytes to gigabytes in SQL query:

    SELECT
    Manufacturer,
    Model,
    [Capacity (Bytes)] / (1024 * 1024 * 1024) AS [Total Memory (GB)]
    FROM vHWPhysicalMemory

    You need to use this in SQL Query:

    ics.[Total Physical Memory (Bytes)] / (1024 * 1024 * 1024) AS [Total Physical Memory (GB)]

     

    Thanks,

    IP.



  • 4.  RE: Sql query to convert ram from bytes to gb?

    Posted Apr 08, 2016 11:33 AM

    I cant seem to find the table hwcs...sorry new to sql here.  Can you modify my current query to include that?  Thanks so much.

    Select id._resourceguid as _itemguid, name,[OS Name],id.[Last Logon User], hld.Model, rus.ModifiedDate, ics.[Total Physical Memory (Bytes)]
    from inv_aex_ac_Identification id 
    left join ResourceUpdateSummary rus on rus.ResourceGuid = id._ResourceGuid and rus.InventoryClassGuid ='9E6F402A-6A45-4CBA-9299-C2323F73A506'
    join Inv_HW_Computer_System ics on ics._ResourceGuid = id._ResourceGuid
    join Inv_HW_Logical_Device hld on hld.[Device ID] = ics.[Device ID]



  • 5.  RE: Sql query to convert ram from bytes to gb?
    Best Answer

    Broadcom Employee
    Posted Apr 08, 2016 11:53 AM

    Try this one

    SELECT
    
    id._ResourceGuid AS _ItemGuid,
    Name,
    [OS Name],
    id.[Last Logon User],
    hld.Model,
    rus.ModifiedDate,
    ics.[Total Physical Memory (Bytes)] / (1024 * 1024 * 1024) AS [Total Physical Memory (GB)]
    
    FROM Inv_AeX_AC_Identification id
    
    LEFT JOIN ResourceUpdateSummary rus ON rus.ResourceGuid = id._ResourceGuid AND rus.InventoryClassGuid ='9E6F402A-6A45-4CBA-9299-C2323F73A506'
    JOIN Inv_HW_Computer_System ics ON ics._ResourceGuid = id._ResourceGuid
    JOIN Inv_HW_Logical_Device hld ON hld.[Device ID] = ics.[Device ID]


  • 6.  RE: Sql query to convert ram from bytes to gb?

    Posted Apr 08, 2016 12:15 PM

    Thanks so much for your help!