ALTER PROCEDURE [dbo].[sp_Tasks] 
@CustomerCode varchar(10),
@ProjectCode varchar(10)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	
	select t.recId AS TaskId, t.taskNumber AS TaskNumber, t.customerCode, t.projectCode,
	(SELECT name FROM pal_Project WHERE projectCode = t.projectCode and customerCode = t.customerCode) AS Project, 
	c.display AS Canvas, y.taskType AS [Type], a.taskCategory AS [Category], t.name AS Name, ui.name AS [Initiator], ua.name AS Assignee, s.taskStatus AS [Status]
	from pal_Task t 	
	left outer join pal_Canvas c on c.recId = t.canvasId 
	left outer join pal_TaskType y ON y.recId = t.taskTypeId
	left outer join pal_TaskCategory a ON a.recId = t.taskCategoryId 
	left outer join pal_User ui ON ui.recId = t.initiatorUserId
	left outer join pal_User ua ON ua.recId = t.assigneeUserId 
	left outer join pal_TaskStatus s on s.recId = t.taskStatusId 
	where t.customerCode = @CustomerCode AND t.projectCode = @ProjectCode
	order by TaskNumber

END