Apparently WQL does not contain an ORDER BY
clause. Is there a way to sort the result set based on one of the columns? For example:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
sSQL = "Select Time,Source,Event,CategoryNum,Category,TypeNum,Type,User,ComputerName,Insertion1,Insertion2,Data from Win32_NTLogEvent Where Logfile = 'System' and SourceName = 'Service Control Manager'"
Set resultSet = objWMIService.ExecQuery (sSQL)
For Each objEvent In resultSet
...
Next
Is there a way to sort resultSet
by the Time
column?
WQL indeed doesn't have an ordering clause, so sorting directly in the query is not possible. What you can do is put the returned data in a disconnected recordset and then sort the recordset:
Adjust the data type of the fields as required.