SQL Policy to Filter relationship
Created: 20 Jul 2010 | 3 comments
Has anyone run across a table(s) or view(s) in SQL that can link a filter to what Policies it is referenced by?
I have tried the following but the problem with the view vPolicyAppliesToResource is that it only works if there is at least one machine in the filter:
Any ideas would be greatly appreciated.
------Step 1-----Returns ResourceTargetFilter Guid
SELECT [ParentItemGuid]
FROM [vItemReference]
where [ChildItemGuid] = 'c8edf1e4-6baf-484c-8129-5ed8604ed43b' -- Software X Filter Guid
-----Step 2-----Use ResourceTargetFilter GIUD to Get Install Policy
select * from vPolicyAppliesToResource
where ResourceTargetGuid = '88500DE4-2348-4A8C-9E4F-4621DC3D4D26' -- ResourceTargetFilter
Discussion Filed Under:
Comments
Anyone have an update on this?
Basically, I just want a list of all software policies assigned to a filter.
You can do this manually the long way by running these four queries:
I'm no SQL genius so surely there is a better way to do this.
Any help would be very much appreciated.
Cheers,
Rhys
Answer from another non SQL genius
Hey Rhys,
Give this a try. It may not be the most efficient way to do this but it works. I had to do something similar for a workflow I did. I baiscally started with the step 4 query and worked my way back to step 1 replacing the Guid with the sql query in the previous step. Let me know if it works out.
Good Luck!
SELECT vi.[Name]
FROM vItem vi
WHERE vi.[Guid] = (SELECT DISTINCT vp.[PolicyGuid]
FROM vPolicyAppliesToResource vp
WHERE vp.[ResourceTargetGuid] = (SELECT vir.[ParentItemGuid]
FROM vItemReference vir
WHERE vir.[ChildItemGuid] = (SELECT vi.[Guid]
FROM vItem vi
WHERE vi.Name = 'YOUR FILTER NAME')))
Thanks Bondo!
That works really well.
Only problem is if there is more than one software resource assigned to the filter, I get the following error:
Would you like to reply?
Login or Register to post your comment.