Skip to main content

Find Rules Assigning Inactive Users

These queries will find rules that set fields with user prompts or Reader queues where the user is inactive or missing.

User Fields (i.e. Staff Assigned)

SELECT r.[id]
ย  ย  ,r.[name]
ย  ย  ,r.[folder]
ย  ย  ,r.[user]
ย  ย  ,u.*
FROM (
ย  ย  SELECT [xml].value('(p[k="prompt"]/v)[1]', 'varchar(64)') AS [user]
ย  ย  ย  ย  ,*
ย  ย  FROM [rule]
ย  ย  WHERE 1 = 1
ย  ย  ย  ย  AND [xml].value('(p[k="field"]/v)[1]', 'varchar(250)') = 'user'
ย  ย  ย  ย  AND [active] = 1
ย  ย  ) r
LEFT JOIN [user] u
ย  ย  ON r.[user] = u.[user]
WHERE u.[active] = 0
ย  ย  OR u.[id] IS NULL

Reader Queues

SELECT r.[id]
ย  ย  ,r.[name]
ย  ย  ,r.[folder]
ย  ย  ,r.[user]
ย  ย  ,u.*
FROM (
ย  ย  SELECT [xml].value('(p[k = "queue_user"]/v)[1]', 'varchar(64)') AS [user]
ย  ย  ย  ย  ,*
ย  ย  FROM [rule]
ย  ย  WHERE 1 = 1
ย  ย  ย  ย  AND [xml].exist('p[k = "queue_user"]/v') = 1
ย  ย  ย  ย  AND [active] = 1
ย  ย  ) r
LEFT JOIN [user] u
ย  ย  ON r.[user] = u.[id]
WHERE u.[active] = 0
ย  ย  OR u.[id] IS NULL