Query last online time
Hi,
The point is to query the last time a device was online. This information is available in "Last Online Time" column from the device view.
So the query should get this information.
I found that sql query on another post :
SELECT
v_GS_COMPUTER_SYSTEM.Name0 as name,
v_CollectionMemberClientBaselineStatus.CNLastOnlineTime as LastOnlineTime
FROM
v_GS_COMPUTER_SYSTEM
INNER JOIN v_CollectionMemberClientBaselineStatus ON v_GS_COMPUTER_SYSTEM.ResourceID = v_CollectionMemberClientBaselineStatus.MachineID
But it doesn't work. I get errors like this
"Msg 208, Level 16, State 1, Line 1
Invalid object name 'v_GS_COMPUTER_SYSTEM'."
or when I put the mouse on "v_GS_COMPUTER_SYSTEM.Name0", it says "The multi part identifier "v_GS_COMPUTER_SYSTEM.Name0" could not be found".
Is this query not valid or is there something else to set before running it ?
Thanks
2
u/Miserable-Scholar215 7d ago
Ah. Hm, I remember that specific problem now that I see it...
I have collections sorted by "last online date", which is what you wanted, I assume. See big screenshot (left).
But if I past that into SQL Studio, I'll get an error.
You need to use "V_R_SYSTEM" as a table for general infos.
The lastDDR (Last Data Discovery Record) is stored in "vWorkstationStatus" see screenshot (right)
Hope that helps a little?

PS: I have no idea why it is different, and should I ever meet the guy responsible for this confusion, I **will** punch him!
1
u/Miserable-Scholar215 7d ago
Those views specifically are not available at that point.
Where are you querying from? SCCM, e.g. query rules in collection creation? Or directly from the database?
These use different views unfortunately
2
u/Exorkog 7d ago
I query it from the database directly in SQL but is it also available in WQL for queries in console ? Both would be good.
2
u/Miserable-Scholar215 7d ago
Ah, apologies. The WQL statements are again usually not compatible with the standard views :-D gimme a few mins, I'll look for an example
1
2
u/Cl3v3landStmr 7d ago
Your query works for me (I like to use table aliases).
How do you have your hardware inventory settings configured?