Inventory Query for the last 60 days
Hi,
This query gives me the computer name and it's IP address:
SELECT SYS.Netbios_Name0,
IPAddr.IP_Addresses0
FROM v_R_System SYS
LEFT JOIN v_RA_System_IPAddresses IPAddr on SYS.ResourceID = IPAddr.ResourceID
I need the report to include information for the last 60 days only. Besides enabling the maintenance task to delete aged inventory history, is there a way to query the info for the last 60 days?
Thank you. Systems Engineer
May 6th, 2010 10:23am
60 days based on what? Last hardware inventory? Heartbeat? Software inventory? Any discovery method?
Free Windows Admin Tool Kit Click here and download it now
May 6th, 2010 11:03am
60 days based on hardware inventory changes.Systems Engineer
May 6th, 2010 11:10am
This is not SQL but WQL so you just need to look up the appropriate values but here is how you would do it. You need to use the dateadd or datediff to accomplish it. In simple terms you can look at this below. Lasthardware scan is
the Hardware inventory date.
where SMS_G_System_WORKSTATION_STATUS.LastHardwareScan >= DateAdd(dd,-60,GetDate()) )
Here is a link on how to use dateadd in SQL:
http://msdn.microsoft.com/en-us/library/ms186819.aspx
http://www.sccm-tools.com http://sms-hints-tricks.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
May 6th, 2010 2:51pm
Hi Matthew,
I added SMS_G_System_WORKSTATION_STATUS.LastHardwareScan >= DateAdd(dd,-60,GetDate()) to my query and I got the following error:
An error occurred when the report was run. The details are as follows:
The multi-part identifier "SMS_G_System_WORKSTATION_STATUS.LastHardwareScan" could not be bound.
Any idea?Systems Engineer
May 6th, 2010 3:29pm
Remember I said that was pulled from WQL not SQL. I am finally at my desk.
you will need to do the joins for v_GS_WORKSTATION_STATUS.ResourceID and
SYS.ResourceID
v_GS_WORKSTATION_STATUS.LastHWScan
is the SQL part that you need
http://www.sccm-tools.com http://sms-hints-tricks.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
May 6th, 2010 9:33pm
Thank you Matthew. I am not an SQL savvy though, i will try to come up with the SQL statement.Systems Engineer
May 10th, 2010 3:34pm