我有以下查询,它在 SSMS 中完美执行。但是,当我将代码粘贴到新创建的数据集并单击“执行”时,BIDS 崩溃并在没有通知的情况下关闭 - 关于原因的任何建议?
代码:
SELECT MSP_EpmProject_UserView.ProjectOwnerName,
MSP_EpmProject_UserView.ProjectUID,
CurrentActivities.Activities_Current
FROM MSP_EpmProject_UserView
Left Join
(Select t1.projectUID, STUFF(
(Select ', ' + t2.TaskName
From (SELECT MSP_EpmProject_UserView.ProjectUID, MSP_EpmTask_UserView.TaskName
FROM MSP_EpmAssignmentByDay_UserView INNER JOIN MSP_EpmTask_UserView ON MSP_EpmAssignmentByDay_UserView.TaskUID = MSP_EpmTask_UserView.TaskUID INNER JOIN MSP_EpmProject_UserView on MSP_EpmAssignmentByDay_UserView.ProjectUID = MSP_EpmProject_UserView.ProjectUID
WHERE (MSP_EpmAssignmentByDay_UserView.TimeByDay = @refDate) AND MSP_EpmProject_UserView.[Project Departments] = @prjDep) t2
Where t1.ProjectUID = t2.ProjectUID
Order by t2.TaskName
For XML Path(''), Type).value('.','varchar(max)'),1,2,'') as Activities_Current
From
(SELECT MSP_EpmProject_UserView.ProjectUID, MSP_EpmTask_UserView.TaskName
FROM MSP_EpmAssignmentByDay_UserView INNER JOIN MSP_EpmTask_UserView ON MSP_EpmAssignmentByDay_UserView.TaskUID = MSP_EpmTask_UserView.TaskUID INNER JOIN MSP_EpmProject_UserView on MSP_EpmAssignmentByDay_UserView.ProjectUID = MSP_EpmProject_UserView.ProjectUID
WHERE (MSP_EpmAssignmentByDay_UserView.TimeByDay = @refDate) AND MSP_EpmProject_UserView.[Project Departments] = @prjDep) t1
Group by t1.ProjectUID) CurrentActivities On CurrentActivities.ProjectUID = MSP_EpmProject_UserView.ProjectUID
WHERE (MSP_EpmProject_UserView.[Project Departments] = @prjDep)