IF NOT EXISTS(SELECT 1 FROM sys.columns 
          WHERE Name = N'TASKNOTE'
          AND Object_ID = Object_ID(N'LD0P0CLIENTTASKS'))
BEGIN
ALTER TABLE LD0P0CLIENTTASKS
	ADD TASKNOTE NVARCHAR(2000)
END
;
IF EXISTS (SELECT 1 FROM SYS.VIEWS WHERE NAME='LD0V0CLIENTTASKS')
BEGIN
DROP VIEW LD0V0CLIENTTASKS
END
;
CREATE VIEW LD0V0CLIENTTASKS AS
	SELECT * FROM LD0P0CLIENTTASKS
;
IF EXISTS (SELECT 1 FROM SYS.VIEWS WHERE NAME='LD0V1CLIENTTASKS')
BEGIN
DROP VIEW LD0V1CLIENTTASKS
END
;
CREATE VIEW LD0V1CLIENTTASKS  AS
 SELECT   
 CT.ID,  
 T.TASKID, 
 CT.PROCESSMETADATAID,  
 CT.CASEWORKERID,    
 CT.ORGANIZATIONUNITID,  
 CT.ORGANIZATIONID,  
 CT.ISCOMPLETED,  
 T.PROCESSID,  
 CT.COMPLETEDDATE,  
 V2.NAMN AS CASEWORKERNAME,  
 J1.NAMN AS CASEWORKERORGANIZATIONNAME,
 CT.TASKNOTE  
 FROM LD0V0TASK T  
 INNER JOIN LD0P0CLIENTTASKS CT ON T.TASKID = CT.TASKID  
 LEFT JOIN LD0V0I V2 ON CT.CASEWORKERID = V2.HAND   
 LEFT JOIN LD0V0J01 J1 ON CT.ORGANIZATIONID = J1.ORGID AND CT.ORGANIZATIONUNITID = J1.ORGENHNR
;