It is nice to see someone get some use out bits of my hackery :)
If the mydatabaseserver has been replaced correctly it should just work but I've not tested w/ a default instance of sql 2000 yet so you may have to google out the proper connection string.
Are you certain you are defining it as an action script and not an active monitor?
I don't think that it is as easy as your query makes it out to be. I think it needs to look something like this:
SELECT DISTINCT Device.nDeviceID
FROM Device
WHERE Device.bRemoved = 0 AND (Device.nDeviceID IN (
SELECT Device.nDeviceID
FROM Device
INNER JOIN PivotActiveMonitorTypeToDevice
ON Device.nDeviceID = PivotActiveMonitorTypeToDevice.nDeviceID
INNER JOIN ActiveMonitorType
ON ActiveMonitorType.nActiveMonitorTypeID = PivotActiveMonitorTypeToDevice.nActiveMonitorTypeID
INNER JOIN ActionPolicy
ON PivotActiveMonitorTypeToDevice.nActionPolicyID = ActionPolicy.nActionPolicyID
WHERE ActionPolicy.nPolicyID = 1055))
I was able to get dynamically created groups created by associating attributes with all of my devices then running complex sql scripts defining dynamic groups based on these attributes (all devices are in the root area in this case and all groups are just dynamic views. I can give you a hint that if you go this route (probably not recommended to be honest, it is far outside of what you are meant to do) that you need to make sure that permissions on the devices/sub-groups populate. Here is a crude way of doing this, depending on how many sub-groups you have it might take multiple runs. Use at your own risk.
-- Update permissions
INSERT INTO Pivotwebusertodevicegroup (
nWebUserID,
nDeviceGroupID,
bGroupRead,
bGroupWrite,
bDeviceRead,
bDeviceWrite
)
SELECT
usr1.nWebUserID AS webuser,
grp1.nDeviceGroupID AS matchgroup,
usr1.bGroupRead,
usr1.bGroupWrite,
usr1.bDeviceRead,
usr1.bDeviceWrite
FROM Pivotwebusertodevicegroup usr1, DeviceGroup grp1
WHERE
grp1.nparentgroupid=usr1.nDeviceGroupID
and grp1.nDeviceGroupID > 3
EXCEPT
SELECT nWebUserID,nDeviceGroupID,bGroupRead,bGroupWrite,bDeviceRead,bDeviceWrite
FROM Pivotwebusertodevicegroup