--Use to differentiate the columns of assign to from assign_to1 to assign_to10
IF NOT EXISTS (
    SELECT * 
    FROM sys.columns 
    WHERE object_id = OBJECT_ID('wko_ls7') 
    AND name = 'wko_ls7_remark'
)
BEGIN
    ALTER TABLE wko_ls7
    ADD wko_ls7_remark varchar(1000) NULL
END


DELETE	cf_label
WHERE	table_name = 'wko_ls7'
AND 	column_name = 'wko_ls7_remark'
GO

INSERT 	cf_label (language_cd, table_name, column_name, 
		default_label,
		customize_label, 
		default_header, 
		customize_header, 
		cfr_flag, cf_label_required, audit_user, audit_date ) 
SELECT 	language_cd, 'wko_ls7', 'wko_ls7_remark', 
		'Remark:', 
		'Remark:', 
		'Remark', 
		'Remark', 
		'0', '0', 'admin', getdate() 
FROM	cf_language 
GO

update wko_ls7 set wko_ls7_remark = (Select 'Assigned to ' + wko_det_assign_to from wko_det where wko_det.site_cd = wko_ls7.site_cd and wko_det.mst_rowid = wko_ls7.mst_rowid and wko_det_assign_to is not null)
GO
