I am trying to create a report that will show an asset that has had a state change within the past 24 hours. This report will be used to auto email the asset manager that an asset has changed, for example: we take an asset out of service to be recycled. The state would change from Active to Recycled. I tried to reference the tblAssts.LastChanged field, but it does not seem to update when there is a state change. Please see the code below:
Select Top 1000000 tblSystemEnclosure.SMBIOSAssetTag As [Asset Tag],
tblSystemEnclosure.SerialNumber As [Serial Number],
tblAssets.AssetName,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tblState.Statename As Status,
tblAssetCustom.Location,
tblAssets.LastChanged As [Date Changed]
From tblAssets
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
Left Outer Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblSystemEnclosure
On tblAssets.AssetID = tblSystemEnclosure.AssetID
Inner Join tblState On tblAssetCustom.State = tblState.State
Where tblAssets.LastChanged >= GetDate() - 1 And tblAssets.AssetUnique
Like '%\D___-%' And tblAssetCustom.State <> 1 And
tblDiskdrives.Caption = 'c:'