Solved

SQL Statement to Query list of PCs - SCCM 2012

Posted on 2014-09-28
3
195 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 100 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 400 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

705 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