Adding Modules to Helix Categories (post rollover)

insert into [BBLEARN].[dbo].[HELIX_COURSE_CATEGORIES]
select [BbAStRAIntegration].[dbo].[pau_v_GetAddModCSV].EXTERNAL_COURSE_KEY AS course_code,COURSE_NAME as course_title, hlx_c_xr.CategoryId as category_id, hlx_c_xr.CategoryName as category_name from
[BbAStRAIntegration].[dbo].[pau_v_GetModDeptCSV]
JOIN [BbAStRAIntegration].[dbo].[pau_v_GetAddModCSV] on [BbAStRAIntegration].[dbo].[pau_v_GetModDeptCSV].EXTERNAL_COURSE_KEY = [BbAStRAIntegration].[dbo].[pau_v_GetAddModCSV].EXTERNAL_COURSE_KEY
JOIN OPENDATASOURCE(‘SQLNCLI’ , ‘Data Source=SQL3\SYSTEMS;Integrated Security=SSPI’).vls.dbo.tbl_Group hlx_g ON hlx_g.GroupName = (CASE
WHEN EXTERNAL_CATEGORY_KEY = ‘A’ THEN ‘_filmtv’
WHEN EXTERNAL_CATEGORY_KEY = ‘B’ THEN ‘_education’
WHEN EXTERNAL_CATEGORY_KEY = ‘C’ THEN ‘_english’
WHEN EXTERNAL_CATEGORY_KEY = ‘D’ THEN ‘_eurolang’
WHEN EXTERNAL_CATEGORY_KEY = ‘E’ THEN ‘_history’
WHEN EXTERNAL_CATEGORY_KEY = ‘F’ THEN ‘_arts’
WHEN EXTERNAL_CATEGORY_KEY = ‘G’ THEN ‘_welsh’
WHEN EXTERNAL_CATEGORY_KEY = ‘I’ THEN ‘_ibers’
WHEN EXTERNAL_CATEGORY_KEY = ‘K’ THEN ‘_interpol’
WHEN EXTERNAL_CATEGORY_KEY = ‘L’ THEN ‘_lawdept’
WHEN EXTERNAL_CATEGORY_KEY = ‘M’ THEN ‘_maths’
WHEN EXTERNAL_CATEGORY_KEY = ‘N’ THEN ‘_compsci’
WHEN EXTERNAL_CATEGORY_KEY = ‘P’ THEN ‘_instes’
WHEN EXTERNAL_CATEGORY_KEY = ‘Q’ THEN ‘_sportsci’
WHEN EXTERNAL_CATEGORY_KEY = ‘T’ THEN ‘_physics’
WHEN EXTERNAL_CATEGORY_KEY = ‘U’ THEN ‘_dis’
WHEN EXTERNAL_CATEGORY_KEY = ‘V’ THEN ‘_llcentre’
WHEN EXTERNAL_CATEGORY_KEY = ‘W’ THEN ‘_psychology’
WHEN EXTERNAL_CATEGORY_KEY = ‘Y’ THEN ‘_smba’
WHEN EXTERNAL_CATEGORY_KEY = ‘Z’ THEN ‘_cont.ed’
WHEN EXTERNAL_CATEGORY_KEY = ‘S’ THEN ‘_ibers’
ELSE EXTERNAL_CATEGORY_KEY END
)
JOIN OPENDATASOURCE(‘SQLNCLI’ , ‘Data Source=SQL3\SYSTEMS;Integrated Security=SSPI’).vls.dbo.tbl_Group_Category_Xref hlx_xr ON hlx_xr.GroupID = hlx_g.GroupID AND hlx_xr.AccessType = 1 AND hlx_xr.CategoryID >= 9 and hlx_xr.CategoryID <= 28
JOIN OPENDATASOURCE('SQLNCLI' , 'Data Source=SQL3\SYSTEMS;Integrated Security=SSPI').vls.dbo.tbl_Category hlx_c_xr ON hlx_c_xr.CategoryID = hlx_xr.CategoryID