SCCM – SQL – Edit SMS Query in CM Database – Hung Query

email me

So, when I was creating and testing a new query in SCCM, I noticed I could no longer click the properties of my query (what’s up with that, Microsoft?). It was due to a syntactical error in the query, which, normally, the query just won’t run, but properties work just fine.

Strangely, there was no way to get around this problem in the console. My query was hung. At first, I thought it was just a record lock issue, but…it wasn’t. Upon further investigation, I realized I should try to modify the query directly in the DB. Once I found where the queries were located in the DB, I updated my query, and tested. That worked!

Here is how you do it:

1 – Open SQL Server Management Studio
2 – Click on the CM DB
3 – Expand Tables
4 – Right click dbo.queries and edit the top X amount of rows
5 – Find your Query in the WQL column
6 – Edit the query directly
7 – Hit Enter, to save
8 – Test Query in SCCM

Screenshot (click to zoom)