Solved

I want to run the following querries against my SCCM database

Posted on 2015-02-18
4
246 Views
Last Modified: 2016-10-13
I want to run the following querries against my SCCM database

SELECT * FROM ResPolicyMap WHERE machineid = 0 and PADBID IN (SELECT PADBID FROM PolicyAssignment WHERE BodyHash IS NULL)
 
 
This one will remove any bad policies if there are any.
 
Delete FROM ResPolicyMap WHERE machineid = 0 and PADBID IN (SELECT PADBID FROM PolicyAssignment WHERE BodyHash IS NULL)

i get the error

Msg 208, Level 16, State 1, Line 1
Invalid object name 'ResPolicyMap'.
0
Comment
Question by:Helao Mwapangasha
  • 2
4 Comments
 
LVL 45

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40616343
Check if you are running the query in the correct database context.
0
 
LVL 3

Author Comment

by:Helao Mwapangasha
ID: 40616387
will i do this in SQL or in SCCM admin Console under queries?
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40616399
I don't know SCCM. I was talking about SQL Server only. If you run for example in SQL Server Management Studio (SSMS) you need to pick up the database first in the query window or add the USE command before the query:
USE SCCM_DBNameHere
GO
Delete FROM ResPolicyMap 
WHERE machineid = 0 and PADBID IN (SELECT PADBID FROM PolicyAssignment WHERE BodyHash IS NULL)

Open in new window

0
 

Expert Comment

by:XCOP91 gmail
ID: 41842015
From SQL management studio, click new query, select database CM_sitename. then run your query.
It is highly recommended not to use any query which deletes or update SCCM database. The query which your are gonna run will delete all policy associations which might put you in trouble. So please run this if you are fully confident and aware. :)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now