
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2021 10:07 PM
I have the following simple query that is listing all monitors with their connected PC's.
However I can't get in the list the Asset ID of the monitor ? I need the Name, serial number and Asset ID for both the monitor and the PC.
Select Top 1000000 tsysOS.Image As icon,
tblAssets.AssetID As pc_asset_id,
tblAssets.AssetName As pc_asset_name,
tblMonitor.AssetID As monitor_asset_id,
tblMonitor.MonitorManufacturer As [Manufacturer Monitor],
tblMonitor.MonitorModel,
tblMonitor.SerialNumber,
tblMonitor.ManufacturedDate,
tblAssets.Domain,
tblAssets.Username,
tblAssets.Userdomain,
tblAssets.IPAddress,
tblAssets.Description,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblAssetCustom.Location,
tblAssetCustom.Custom1 As asset_tag,
tsysIPLocations.IPLocation,
tsysOS.OSname As OS,
tblAssets.SP As SP,
tblAssets.Firstseen,
tblAssets.Lastseen
From tblAssets
Inner Join tblMonitor On tblMonitor.AssetID = tblAssets.AssetID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysOS On tblAssets.OScode = tsysOS.OScode
Left Join tsysIPLocations On tsysIPLocations.StartIP <= tblAssets.IPNumeric
And tsysIPLocations.EndIP >= tblAssets.IPNumeric
Where tblAssetCustom.State = 1
Order By pc_asset_name
Solved! Go to Solution.
- Labels:
-
Report Center
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2021 06:06 PM
Either of these will get you started pulling the monitor data from tblAssets. The result is the same, only one filters by the asset type descriptive name while the other skips that and just uses the AssetType numeric value. (You can "SELECT * FROM tSysAssetTypes" to see the full list.) Either way, because you're linking tblAssets to tblAssets, you need to use tblAssetRelations for the asset-to-asset connection.
SELECT Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
monitor.AssetID,
monitor.AssetName
FROM
tblAssets
INNER JOIN tSysAssetTypes AS aType ON aType.AssetType = tblAssets.AssetType AND aType.AssetTypename = 'Windows'
INNER JOIN tblAssetRelations ON tblAssetRelations.ParentAssetID = tblAssets.AssetID
INNER JOIN tblAssets AS monitor ON monitor.AssetID = tblAssetRelations.ChildAssetID
INNER JOIN tSysAssetTypes AS mType ON mType.AssetType = monitor.AssetType AND mType.AssetTypename = 'Monitor'
ORDER BY
tblAssets.AssetName,
monitor.AssetName
SELECT Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
monitor.AssetID,
monitor.AssetName
FROM
tblAssets
INNER JOIN tblAssetRelations ON tblAssetRelations.ParentAssetID = tblAssets.AssetID
INNER JOIN tblAssets AS monitor ON monitor.AssetID = tblAssetRelations.ChildAssetID AND monitor.AssetType = 208 -- monitor
WHERE
tblAssets.AssetType = -1 -- Windows
ORDER BY
tblAssets.AssetName,
monitor.AssetName
You should be able to build up your query using either of those as a base.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2024 05:26 AM
I need regular inventory by location. While PC's have a location (set by Active Directory OU), it's still leaving out all docking stations and monitors, even though the information is in there. How can those devices all be automatically bulk-set to match the connected computer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2021 03:33 PM
SELECT
pc.AssetID AS [PC AssetID],
pc.AssetName AS [PC AssetName],
monitor.AssetID AS [Monitor AssetID],
monitor.AssetName AS [Monitor AssetName],
monitorCustom.Model AS [Monitor Model],
monitorCustom.Serialnumber As [Monitor Serial]
FROM
tblAssets AS monitor
LEFT JOIN tblAssetRelations ON tblAssetRelations.ChildAssetID = monitor.AssetID
LEFT JOIN tblAssets AS pc ON pc.AssetID = tblAssetRelations.ParentAssetID AND pc.AssetType = -1
INNER JOIN tblAssetCustom as monitorCustom ON monitorCustom.AssetID = monitor.AssetID
WHERE
monitor.AssetType = 208
ORDER BY
pc.AssetName,
monitor.AssetName,
monitorCustom.SerialNumber

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2021 04:20 PM
Select Top 1000000 tblAssets.AssetName As pc_asset_name,
tblAssets.AssetID As pc_asset_id,
monitor.AssetName As monitor_asset_name,
monitor.AssetID As monitor_asset_id,
tblAssetCustom.Custom1 As monitor_asset_tag,
tblAssetCustom.Serialnumber As monitor_serial_number
From tblAssets
Inner Join tblAssetRelations On tblAssetRelations.ParentAssetID =
tblAssets.AssetID
Inner Join tblAssets As monitor On
monitor.AssetID = tblAssetRelations.ChildAssetID And monitor.Assettype = 208
Inner Join tblAssetCustom On monitor.AssetID = tblAssetCustom.AssetID
Where (tblAssets.Assettype = -1 Or tblAssets.Assettype = 208)
Order By pc_asset_name,
monitor_asset_name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2021 06:06 PM
Either of these will get you started pulling the monitor data from tblAssets. The result is the same, only one filters by the asset type descriptive name while the other skips that and just uses the AssetType numeric value. (You can "SELECT * FROM tSysAssetTypes" to see the full list.) Either way, because you're linking tblAssets to tblAssets, you need to use tblAssetRelations for the asset-to-asset connection.
SELECT Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
monitor.AssetID,
monitor.AssetName
FROM
tblAssets
INNER JOIN tSysAssetTypes AS aType ON aType.AssetType = tblAssets.AssetType AND aType.AssetTypename = 'Windows'
INNER JOIN tblAssetRelations ON tblAssetRelations.ParentAssetID = tblAssets.AssetID
INNER JOIN tblAssets AS monitor ON monitor.AssetID = tblAssetRelations.ChildAssetID
INNER JOIN tSysAssetTypes AS mType ON mType.AssetType = monitor.AssetType AND mType.AssetTypename = 'Monitor'
ORDER BY
tblAssets.AssetName,
monitor.AssetName
SELECT Top 1000000
tblAssets.AssetID,
tblAssets.AssetName,
monitor.AssetID,
monitor.AssetName
FROM
tblAssets
INNER JOIN tblAssetRelations ON tblAssetRelations.ParentAssetID = tblAssets.AssetID
INNER JOIN tblAssets AS monitor ON monitor.AssetID = tblAssetRelations.ChildAssetID AND monitor.AssetType = 208 -- monitor
WHERE
tblAssets.AssetType = -1 -- Windows
ORDER BY
tblAssets.AssetName,
monitor.AssetName
You should be able to build up your query using either of those as a base.
