ALTER TABLE R5LISTENTITY ADD LET_CATEGORY NVARCHAR(20) NULL;

UPDATE r5listentity SET let_category = 'EVNT'
WHERE let_datagrid in ('WCJOBS_FULL_IPAD','WCMATL_IPAD','WCACTJ_FULL_IPAD','WCBKEV','BCCOMWO','WCTRAN','WCTRAL','WCTOOL_IPAD','WCJTPL_IPAD','WCJTOU_IPAD','ICRSLT','WCSCHED_IPAD','WCMISC_IPAD','WCNOCF_IPAD','BCPROMWO','WCDFAC_IPAD','WCATCP_IPAD','WCMATLIST_IPAD','BCCOMWONOCF_IPAD','BCDOCWONOCF_IPAD','NEW_BCPROMNOCF_IPAD','BCDOCWO_IPAD');

UPDATE r5listentity SET let_category = 'EVNT'
WHERE let_datagrid like '%_MEC%';

UPDATE r5listentity SET let_category = 'OBJ'
WHERE let_datagrid in
('OCOBJC_FULL_IPAD','OCUSGD_IPAD','BCDOCOBJ_IPAD','BCPROMOBJ','BCCOMOBJ');

DELETE FROM R5LISTENTITY WHERE LET_DATAGRID IN ('OCJOBH_IPAD','OCJOBHWO_IPAD','BCCOMOBJHIST_IPAD','BCCOMOBJHISTWO_IPAD');

UPDATE R5APPSETTINGS SET AST_VALUE = '11207' WHERE AST_NAME='DBVERSION';
