?
Solved

SQL Statement to Query list of PCs - SCCM 2012

Posted on 2014-09-28
3
Medium Priority
?
196 Views
Last Modified: 2014-10-23
Hi Everybody,

I am trying to create list of computers in the collection (SCCM 2012) which has SCCM client installed but I also want to make exception do not include a few computers (example do not include computer start with Test-01)

Here is my Query Statement:

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.Client = "1"


Anybody can help me out with the above issue?

Thanks.

Emese
0
Comment
Question by:Szuromi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 49

Assisted Solution

by:PortletPaul
PortletPaul earned 400 total points
ID: 40349067
you can use NOT LIKE
SELECT
      SMS_R_SYSTEM.ResourceID
    , SMS_R_SYSTEM.ResourceType
    , SMS_R_SYSTEM.Name
    , SMS_R_SYSTEM.SMSUniqueIdentifier
    , SMS_R_SYSTEM.ResourceDomainORWorkgroup
    , SMS_R_SYSTEM.Client
FROM SMS_R_System
WHERE SMS_R_System.Client NOT LIKE 'Test-01%'

Open in new window

0
 
LVL 25

Accepted Solution

by:
Tomas Helgi Johannsson earned 1600 total points
ID: 40349574
Hi!

Depending on the size of the table then you should use EXCEPT like this

SELECT
      SMS_R_SYSTEM.ResourceID
    , SMS_R_SYSTEM.ResourceType
    , SMS_R_SYSTEM.Name
    , SMS_R_SYSTEM.SMSUniqueIdentifier
    , SMS_R_SYSTEM.ResourceDomainORWorkgroup
    , SMS_R_SYSTEM.Client
FROM SMS_R_System 
WHERE SMS_R_SYSTEM.Client = "1"
EXCEPT
SELECT
      SMS_R_SYSTEM.ResourceID
    , SMS_R_SYSTEM.ResourceType
    , SMS_R_SYSTEM.Name
    , SMS_R_SYSTEM.SMSUniqueIdentifier
    , SMS_R_SYSTEM.ResourceDomainORWorkgroup
    , SMS_R_SYSTEM.Client
FROM SMS_R_System 
WHERE SMS_R_SYSTEM.Client = "1"
AND SMS_R_SYSTEM.Name LIKE "Test-01%"

Open in new window


This would work much faster than the not like suggestion above and even more if you have index on the table that has these two columns (Client, Name ) on that table.

Regards,
   Tomas Helgi
0
 

Author Closing Comment

by:Szuromi
ID: 40400238
Thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question