CREATE view View_Change AS SELECT chg.*, chgstat.sym status_name, pri.sym priority_num, chgcat.sym category_name, int_org.org_name organization_name, affected_cnt.last_name affected_end_user_lastname,
affected_cnt.first_name affected_end_user_firstname, affected_cnt.middle_name affected_end_user_middlename, requester.last_name requester_lastname, requester.first_name requester_firstname, requester.middle_name requester_middlename,
requester_org.org_name business, assignee.last_name assignee_lastname,
assignee.first_name assignee_firstname, assignee.middle_name assignee_middlename, View_Group.contact_uuid groupID, View_Group.last_name group_name, srv_desc.sym service_type, impact.sym impact_num, product.sym product_sym,
toc.sym type_of_contact_sym, repmeth.sym rpting_method_sym, perscon.sym person_contacting_sym FROM ((((((((((((((( chg inner join pri ON chg.priority = pri.enum) left join chgstat ON chg.status= chgstat.code)
inner join ca_contact affected_cnt ON chg.affected_contact = affected_cnt.contact_uuid)
inner join ca_contact requester ON chg.requestor = requester.contact_uuid) left join ca_contact assignee ON chg.assignee = assignee.contact_uuid) left join View_Group ON chg.group_id = View_Group.contact_uuid)
left join srv_desc ON chg.support_lev = srv_desc.code) left join ca_organization int_org ON chg.organization = int_org.organization_uuid) left join ca_organization requester_org
ON requester.organization_uuid = requester_org.organization_uuid) left join chgcat ON chg.category = chgcat.code)
left join impact ON chg.impact = impact.enum) left join product ON chg.product = product.id) left join toc ON chg.type_of_contact = toc.id) left join repmeth ON chg.reporting_method = repmeth.id) left join perscon ON chg.person_contacting = perscon.id)
GO
GRANT SELECT ON [dbo].[View_Change] TO [service_desk_admin_group]
GRANT SELECT ON [dbo].[View_Change] TO [service_desk_ro_group]
GO