SCCM Sql query broken in 2012.

Hi, I've been using this query in 2007 and it's working with the machines migrated from 2007 and 2012 but new machines will not show up. Something is amiss with the operatingsystem.resourceID and I can't figure out what.

SELECT

system_resource_n_arr.Resource_names0 as [DNSname],
v_Collection.Name as [Collection], 
v_ServiceWindow.Description as [Description], 
CONVERT(VARCHAR(8), v_ServiceWindow.StartTime, 108) as [Start_Time],
v_ServiceWindow.Duration as [Duration],
v_GS_OPERATING_SYSTEM.Caption0 as [Operating System]

FROM

v_ServiceWindow  
Join 
v_Collection on v_Collection.CollectionID = v_ServiceWindow.CollectionID
Join
v_FullCollectionMembership on v_FullCollectionMembership.CollectionID = v_ServiceWindow.CollectionID
Join
v_GS_OPERATING_SYSTEM on v_GS_OPERATING_SYSTEM.ResourceID = v_FullCollectionMembership.ResourceID
Join
v_R_System on v_R_System.ResourceID = v_FullCollectionMembership.ResourceID
Join
system_resource_n_arr on system_resource_n_arr.itemkey = v_FullCollectionMembership.ResourceID


order by [start_time], [Collection],[DNSname]
July 31st, 2015 4:06pm

Why are you querying a table, specifically system_resource_n_arr? Bad form, you should only ever query views and tables may change without warning.

Also, given that you are using inner joins here, if there is no match in the table, you won't get any data back. Thus, if you don't have any maintenance windows setup, you won't get any data back.

The best way to troubleshoot larger queries like this is to take it step by step. Start with one join and try it. If it works as expected, add the next join. Once the results go awry, you narrowed done your issue to the latest added join or join condition.

Free Windows Admin Tool Kit Click here and download it now
July 31st, 2015 8:27pm

Why are you querying a table, specifically system_resource_n_arr? Bad form, you should only ever query views and tables may change without warning.

Also, given that you are using inner joins here, if there is no match in the table, you won't get any data back. Thus, if you don't have any maintenance windows setup, you won't get any data back.

The best way to troubleshoot larger queries like this is to take it step by step. Start with one join and try it. If it works as expected, add the next join. Once the results go awry, you narrowed done your issue to the latest added join or join cond

August 3rd, 2015 7:49am

v_GS_OPERATING_SYSTEM is retrieved by hardware inventory like almost all other data.

My comment on querying tables still stands: it's a terrible practice to get into and will cause you issues at some point.

Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2015 10:15am

v_GS_OPERATING_SYSTEM is retrieved by hardware inventory like almost all other data.

My comment on querying tables still stands: it's a terrible practice to get into and will cause you issues at some

August 3rd, 2015 10:54am

The simplest way to do this is find the data within CM12 Resource Explorer, once you do that the view name is almost always the same name as the node name v_gs_<node name>.

If the data is found on the computer properties then the view will be v_R_<something> or v_RA_<something> the names are obvious as to what they contain.

Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2015 11:09am

The simplest way to do this is find the data within CM12 Resource Explorer, once you do that the view name is almost always the same name as the node name v_gs_<node name>.

If the data is found on the computer properties then the view will be v_R_<something> or v_RA_<something> the names are obvious as to what they contain.

August 3rd, 2015 2:12pm

v_GS_OPERATING_SYSTEM is retrieved by hardware inventory like almost all other data.

My comment on querying tables still stands: it's a terrible practice to get into and will cause you issues at some

Free Windows Admin Tool Kit Click here and download it now
August 3rd, 2015 2:13pm

This blog might help.

http://www.enhansoft.com/blog/troubleshooting-inventory-flow

August 3rd, 2015 2:26pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics