RC62N wrote:
Refer to this thread. You should be able to use the information there to set up a CASE statement to assign the colours you want.
Thanks RC62N. I was able to figure it out and make some additional changes as well after taking the weekend away from it. Here is my final result:
Select Distinct Top 1000000 tsysOS.Image As Icon,
tblAssets.AssetID,
tblAssets.AssetName As [WorkStation Name],
tsysOS.OSname As OS,
tblAssetCustom.Model,
tblAssets.Domain,
tblAssets.IPAddress,
tsysIPLocations.IPLocation As Site,
tblAssets.Memory,
Cast(CorrectMemory.Used As numeric) As [Slots used],
tblPhysicalMemoryArray.MemoryDevices - CorrectMemory.Used As [Slots free],
tblPhysicalMemoryArray.MemoryDevices As [Slots available],
Case When tblProcessor.Name Not Like 'Intel Core i%' Then '#fbfb86'
End As backgroundcolor,
tblProcessor.Name As [Processor Series],
tblDiskdrives.Caption As Drive,
Cast(Cast(dbo.tblDiskdrives.Size As BigInt) / 1024 / 1024 / 1024 As Numeric)
As [Total size (GB)],
Cast(Cast(dbo.tblDiskdrives.Freespace As BigInt) / 1024 / 1024 /
1024 As Numeric) As [Free Space (GB)],
Cast((Cast(dbo.tblDiskdrives.Size As BigInt) -
Cast(dbo.tblDiskdrives.Freespace As BigInt)) / 1024 / 1024 / 1024 As
Numeric) As [Used Space (GB)],
Case
When Cast(Cast(Cast(dbo.tblDiskdrives.Freespace As BigInt) / 1024 / 1024 /
1024 As Numeric) / Cast(Cast(dbo.tblDiskdrives.Size As BigInt) / 1024 /
1024 / 1024 As Numeric) * 100 As bigint) <= 10 Then 'red'
End As foregroundcolor,
Cast(Cast(Cast(dbo.tblDiskdrives.Freespace As BigInt) / 1024 / 1024 /
1024 As Numeric) / Cast(Cast(dbo.tblDiskdrives.Size As BigInt) / 1024 / 1024 /
1024 As Numeric) * 100 As bigint) As [% Free],
tblAssets.Firstseen,
tblAssets.Lastseen,
tblAssetCustom.PurchaseDate,
Convert(Varchar(10),tblAssetCustom.Warrantydate,101) As [Warranty Expiration]
From tblAssets
Inner Join tblPhysicalMemoryArray On tblAssets.AssetID =
tblPhysicalMemoryArray.AssetID
Inner Join (Select tblAssets.AssetID,
Sum(Ceiling(tblPhysicalMemory.Capacity / 1024 / 1024)) As Memory,
Count(tblPhysicalMemory.Win32_PhysicalMemoryid) As Used
From tblAssets
Left Outer Join (TsysMemorytypes
Right Outer Join tblPhysicalMemory On TsysMemorytypes.Memorytype =
tblPhysicalMemory.MemoryType) On tblAssets.AssetID =
tblPhysicalMemory.AssetID
Group By tblAssets.AssetID,
tblPhysicalMemory.MemoryType
Having tblPhysicalMemory.MemoryType <> 11) CorrectMemory
On CorrectMemory.AssetID = tblAssets.AssetID
Inner Join tsysOS On tblAssets.OScode = tsysOS.OScode
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tblPhysicalMemory On tblAssets.AssetID = tblPhysicalMemory.AssetID
Inner Join TsysMemorytypes On TsysMemorytypes.Memorytype =
tblPhysicalMemory.MemoryType
Inner Join tblProcessor On tblAssets.AssetID = tblProcessor.AssetID
Inner Join tblDiskdrives On tblAssets.AssetID = tblDiskdrives.AssetID
Inner Join tsysIPLocations On tsysIPLocations.LocationID =
tblAssets.LocationID
Where (tblAssets.AssetName Not Like 'BLAHblah-%' And
tsysOS.OSname Not Like 'Win 2%' And tblAssets.Domain = 'BLAH' And
tblDiskdrives.Caption = 'C:' And tblPhysicalMemoryArray.[Use] = 3 And
tblAssetCustom.State = 1) Or
(tsysOS.OSname Not Like 'Win 2%' And tblAssets.Domain = 'BLAHBLAH' And
tblDiskdrives.Caption = 'C:' And tblPhysicalMemoryArray.[Use] = 3 And
tblAssetCustom.State = 1)
Order By Site,
[WorkStation Name]
I've added warranty information as well. Is there a way to assign a foreground color to:
Convert(Varchar(10),tblAssetCustom.Warrantydate,101) As [Warranty Expiration]
I'd like to change the foreground to 'red' for both the 'Warranty Expiration' and the 'Free %'. I'm thinking that once I add 'End As foreground', it closes the foreground so any additional statements with foreground in it fails saying foreground was already used in another column and needs to be unique.
How can I assign a foreground to both the warranty info and the 'Free %'?