Quantcast
Channel: WSUS forum
Viewing all articles
Browse latest Browse all 12874

WSUS Reports - Querying WSUS database

$
0
0

Hi,

   Iam trying to fetch the approved  security and critical updates status for a machine .But the results given by default report and my query are different.Here is the query am using

Declare @ComputerName varchar(200)
Declare @InstallCount as int
Declare @FailedCount as int
Declare @UnknownCount as int
DECLARE cursor_variable CURSOR FOR
SELECT [FullDomainName]     
  FROM [SUSDB].[dbo].[tbComputerTarget] where ([TargetID] in
(SELECT   [TargetID]  FROM [SUSDB].[dbo].[tbTargetInTargetGroup]
where ( [TargetGroupID] in (SELECT [TargetGroupID]
  FROM [SUSDB].[dbo].[tbTargetGroup]where [Name] in
('wks Staging',
'ITInfrastructure',
'wks Production - DOZ',
'wks Service Desk',
'Workstations',
'wks Exception',
'wks FUT',
'Wks Win7 CorpSupport',
'Wks Win7',
'wks Production',
'wks Production - Mindscape',
'wks Production - Al Salam',
'wks Corporate Support',
'wks Corporate Systems',
'IE7 - DOZ',
'IE7 - Mindscape',
'wks Production - DAC',
'wks Pre-Production')))))

OPEN cursor_variable

FETCH Next from cursor_variable INTO @ComputerName
WHILE @@FETCH_STATUS = 0 
BEGIN 
SELECT  @InstallCount=count(Distinct [MSKBNumber])
        FROM [SUSDB].[dbo].[v_AllSecurityAndCriticalUpdatesStatusOnAllComputers] where [Status]='Installed' and [Action]='Install' and computerName=@ComputerName
SELECT  @FailedCount=count(Distinct [MSKBNumber])
        FROM [SUSDB].[dbo].[v_AllSecurityAndCriticalUpdatesStatusOnAllComputers] where [Status]='Failed' and [Action]='Install' and computerName=@ComputerName
SELECT  @UnknownCount=count(Distinct [MSKBNumber])
        FROM [SUSDB].[dbo].[v_AllSecurityAndCriticalUpdatesStatusOnAllComputers] where [Status]='Unknown' and [Action]='Install' and computerName=@ComputerName
Update Workstations set Installed=@InstallCount,Failed=@FailedCount,Unknown=@UnknownCount
where ComputerName=@ComputerName

FETCH Next from cursor_variable INTO @ComputerName
END;


CLOSE cursor_variable;
DEALLOCATE cursor_variable

 I have tried the below of no use

Select  knowledgebasearticle

from PUBLIC_VIEWS.vComputerTarget COMP
join PUBLIC_VIEWS.vUpdateInstallationInfo UINF on COMP.ComputerTargetID = UINF.ComputertargetID
join PUBLIC_VIEWS.vUpdate UPDT on UINF.UpdateID = UPDT.UpdateID
join PUBLIC_VIEWS.vUpdateApproval UDTA on UPDT.UpdateID = UDTA.UpdateID

where classificationID in ('E6CF1350-C01B-414D-A61F-263D14D133B4', '0FA1201D-4330-4FA8-8AE9-B877473B6441')
and  Name='machinename' and [Action]='Install' and (state='1' or state='4' )

what is the mistake am doing?

I want the count of all approved security and critical updates installed on a machine.

Any help?


gowthaman J


Viewing all articles
Browse latest Browse all 12874

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>