‎10-01-2020 04:06 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
Coalesce(tsysOS.Image, tsysAssetTypes.AssetTypeIcon10) As icon,
tblAssets.IPAddress,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname As OS,
tblAssets.Lastseen,
tblDiskdrives.Caption As Drive,
Cast(tblDiskdrives.Freespace / 1024 / 1024 / 1024 As numeric) As FreeGB,
Cast(tblDiskdrives.Size / 1024 / 1024 / 1024 As numeric) As TotalSizeGB,
Ceiling(tblDiskdrives.Freespace / (Case tblDiskdrives.Size
When 0 Then 1
Else tblDiskdrives.Size
End) * 100) As [%SpaceLeft],
tblDiskdrives.Lastchanged As LastChanged,
tblAssetCustom.Custom5
From tblAssets
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
Inner Join tblComputersystem On tblAssets.AssetID = tblComputersystem.AssetID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblDomainroles On tblDomainroles.Domainrole =
tblComputersystem.Domainrole
Left Join tsysOS On tblAssets.OScode = tsysOS.OScode
Where Cast(tblDiskdrives.Size / 1024 / 1024 / 1024 As numeric) <> 0 And
Ceiling(tblDiskdrives.Freespace / (Case tblDiskdrives.Size
When 0 Then 1
Else tblDiskdrives.Size
End) * 100) < 11 And tblState.Statename = 'Active' And
tblDomainroles.Domainrolename In ('Stand-alone server', 'Member server',
'Primary domain controller', 'Backup domain controller') And
Case tblDiskdrives.DriveType
When 3 Then 'Local Disk'
End = 'Local Disk'
Order By tblAssets.AssetName,
Drive
‎10-02-2020 04:24 PM
Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
Coalesce(tsysOS.Image, tsysAssetTypes.AssetTypeIcon10) As icon,
tblAssets.IPAddress,
tsysOS.OSname As OS,
tblAssets.Lastseen,
tblDiskdrives.Caption As Drive,
Cast(tblDiskdrives.Freespace / 1024 / 1024 / 1024 As numeric) As FreeGB,
Cast(tblDiskdrives.Size / 1024 / 1024 / 1024 As numeric) As TotalSizeGB,
Ceiling(tblDiskdrives.Freespace / (Case tblDiskdrives.Size
When 0 Then 1
Else tblDiskdrives.Size
End) * 100) As [%SpaceLeft],
tblDiskdrives.Lastchanged As LastChanged,
tblAssetCustom.Custom5 As [Excluded Storage]
From tblAssets
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
Inner Join tblComputersystem On tblAssets.AssetID = tblComputersystem.AssetID
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tblDomainroles On tblDomainroles.Domainrole =
tblComputersystem.Domainrole
Left Join tsysOS On tblAssets.OScode = tsysOS.OScode
Where Cast(tblDiskdrives.Size / 1024 / 1024 / 1024 As numeric) <> 0 And
Ceiling(tblDiskdrives.Freespace / (Case tblDiskdrives.Size
When 0 Then 1
Else tblDiskdrives.Size
End) * 100) < 16 And tblState.Statename = 'Active' And
tblDomainroles.Domainrolename In ('Stand-alone server', 'Member server',
'Primary domain controller', 'Backup domain controller') And
Case tblDiskdrives.DriveType
When 3 Then 'Local Disk'
End = 'Local Disk' And CharIndex(Left(tblDiskdrives.Caption, 1),
IsNull(tblAssetCustom.Custom5, '')) = 0
Order By tblAssets.AssetName,
Drive
‎10-02-2020 12:58 AM
AND CharIndex(tblDiskdrives.Caption, IsNull(tblAssetCustom.Custom5, '')) = 0
‎10-02-2020 12:27 AM
AND (tblAssetCustom.Custom5 IS NULL -- never populated, nothing to filter against, so include the record
OR CharIndex(tblDiskdrives.Caption, tblAssetCustom.Custom5) = 0 -- populated, even if blank; include the record if current drive is not in the list
)
‎10-01-2020 05:32 PM
AND CharIndex(tblDiskdrives.Caption, tblAssetCustom.Custom5) = 0
AND CharIndex(Left(tblDiskdrives.Caption, 1), tblAssetCustom.Custom5) = 0
‎10-01-2020 10:57 PM
RC62N wrote:
Assuming your Custom5 list formats the drive captions to match tblDiskdrives.Caption (e.g. 'D:,E:,F:'), you should be able to add this to your WHERE clause:AND CharIndex(tblDiskdrives.Caption, tblAssetCustom.Custom5) = 0
If the formatting isn't the same, e.g. if you don't include the colons ('D,E,F' or even 'DEF'), you could achieve the same effect withAND CharIndex(Left(tblDiskdrives.Caption, 1), tblAssetCustom.Custom5) = 0
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now