Query Collection : Multiple Maintenance Window assigned

Vid3al 96 Reputation points
2023-09-25T09:56:07.79+00:00

Starting from the query indicated in the following article, how can the query return only the name of systems that have more than one associated maintenance window?

https://www.prajwaldesai.com/find-sccm-maintenance-windows-for-a-computer/

select
 v_FullCollectionMembership.Name as Computername ,v_Collection.Name as CollectionName,
 v_ServiceWindow.Description as "Maintenance Windows Schedule"
 from v_ServiceWindow
 inner join v_FullCollectionMembership on (v_FullCollectionMembership.CollectionID = v_ServiceWindow.CollectionID)
 inner join v_Collection on (v_Collection.CollectionID = v_FullCollectionMembership.CollectionID)
 order By v_Collection.Name

Thank you for your support.

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,927 questions
Microsoft Configuration Manager
0 comments No comments
{count} votes

Accepted answer
  1. AllenLiu-MSFT 44,826 Reputation points Microsoft Vendor
    2023-09-28T09:11:25.04+00:00

    Hi, @Vid3al

    Thank you for posting in Microsoft Q&A forum.

    select
    
     v_FullCollectionMembership.Name as Computername , COUNT(v_FullCollectionMembership.Name) as MaintenanceWindowsNumber
    
     from v_ServiceWindow
    
     inner join v_FullCollectionMembership on (v_FullCollectionMembership.CollectionID = v_ServiceWindow.CollectionID)
    
     inner join v_Collection on (v_Collection.CollectionID = v_FullCollectionMembership.CollectionID)
    
     group by v_FullCollectionMembership.Name
    
     having COUNT(v_FullCollectionMembership.Name) >= 2
    
    

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Add comment".


1 additional answer

Sort by: Most helpful
  1. Garth 5,801 Reputation points
    2023-09-25T10:59:24.04+00:00

    Look at the Having Sql function, this will allow to get those system having more than one maintenance window.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.