jnelson993
Posts: 959
Score: 132 Joined: 2/18/2005 From: Minneapolis, MN Status: offline
|
Well, I see a couple of things right off the bat that I'd look at... - I'd make that join to v_GS_Service a left join and put a filter in the FROM clause so you only find service records with 'BlackICE' (less to make SQL join and will eliminate some of your YES AND NO problems)
- I think the join to v_GS_System_Enclosure is unnecessary...you're not selecting from it, and having it in the WHERE clause is just making SQL do more work than it has to...unless I'm misunderstanding the reason you're including it, I'd just remove it.
- The join to v_GS_Operating_system is unnecessary...you're not selecting from it, and you're not using it to search/filter anything, so it's just making SQL do more work than it needs to as well.
- Your join to v_FullCollectionMembership just to display the obsolete field and the site code is probably not a great idea as it causes duplicates that have to be filtered out (multiple collections per machine, though you're not filtering out for a single collection) plus all that data can be found in the v_R_System view (obsolete field) and the v_RA_System_SMSAssignedSites (sitecode field) view. Actually, it might make more sense to just remove obsolete records altogether because you might have an obsolete record that shows Proventia as Uninstalled, but have an active record for the same machine that shows it as installed. Is there a reason to SHOW the obsolete records? They're going to be deleted by a maintenance task anyway.
- The left join to you client health results won't act like a left join because you've got a filter predicate for CHR in the WHERE clause. That causes the query to act like an INNER JOIN -->READ THIS<-- for more info. I'd make it an INNER JOIN and move the filter predicate up to the FROM
- BTW, you don't need a DTS job to get the data from the client health db into your SMS db -->READ THIS<-- if you want more info.
Other than that...I don't really see any problems :) So, I'm thinking something more like this: (Untested as I don't have your client health table) SELECT DISTINCT sys.Netbios_Name0, sc.SiteCode, sys.User_Domain0, sys.User_Name0, sys.Operating_System_Name_and0, DateDiff(DAY,WK.LastHWScan,getdate()) AS 'Last HW Scan', sys.AD_Site_Name0 AS [AD Site name], CASE sys.Client_version0 WHEN '2.50.3174.1018' THEN 'SMS SP1 Client' WHEN '2.50.4160.2000' THEN 'SMS SP2 Client' WHEN '2.50.4253.3000' THEN 'SMS SP3 Client' ELSE ' SMS 2.0 Client' END AS [Client Version], CHR.LastPingResult, CHR.LastPing, DateDiff(DAY,CHR.LastPing,getdate()) AS [Days Last Ping], CASE SRV.DisplayName0 WHEN 'BlackICE' THEN 'Yes' ELSE 'No' END AS [Proventia Installed ?] FROM v_R_System sys INNER JOIN v_ClientHealthResults CHR ON SYS.ResourceID = CHR.ResourceID AND CHR.LastPingResult LIKE '% Access Denied' LEFT JOIN v_RA_System_SMSAssignedSites sc ON sys.ResourceID = sc.ResourceID LEFT JOIN v_GS_Workstation_Status AS WK ON SYS.ResourceID = WK.ResourceID LEFT JOIN v_GS_SERVICE SRV ON SYS.ResourceID = SRV.ResourceID AND srv.DisplayName0 = 'BlackICE' WHERE sys.Operating_System_Name_and0 NOT LIKE '%SERVER%' AND sys.obsolete0 = 0 AND sys.decommissioned0 = 0 AND sys.client0 = 1 ORDER BY sys.Netbios_Name0
_____________________________
Number2 (John Nelson) MyITForum - Blog MyITForum - Forum Posts
|