Solved

I want to run the following querries against my SCCM database

Posted on 2015-02-18
4
283 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 47

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 47

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql query 8 50
ORA-00923: FROM keyword not found where expected 3 66
SQL Server merge records in one table 2 24
Problem when I run a simple storeproc - help 4 17
Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 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