We have a sql statement as below and as we try to add to the where clause through the sc_select_where macro, we get nm_sel_esp inserted in the wrong place creating a sql error. This was working fine before the recent updates and suddenly broke.
SELECT
TaskID,
InitiatedEmployeeID,
CreatedDateTime,
Subject,
Body,
LastModifiedBy,
LastModifiedDate,
ChangeHistory,
(SELECT TOP 1 EmployeeID FROM TaskEmployeeInfo
WHERE TaskInfo.TaskID = TaskEmployeeInfo.TaskId AND Responsible = 1) AS Responsible,
(SELECT TOP 1 IsRead FROM TaskEmployeeInfo
WHERE TaskInfo.TaskID = TaskEmployeeInfo.TaskId AND TaskEmployeeInfo.EmployeeID = [EmployeeID]) AS IsRead,
Status AS TaskStatus,
EmployeeComments AS EmployeeComments
FROM
TaskInfo
WHERE 1=1
ORDER BY Closed, IsRead ASC, LastModifiedDate DESC
SC9 produces the following which results in an error
…
Status AS TaskStatus, EmployeeComments AS EmployeeComments FROM dbo.TaskInfo WHERE 1=1 ) nm_sel_esp
WHERE ((TaskID in (SELECT TaskId FROM TaskEmployeeInfo WHERE TaskEmployeeInfo.EmployeeID = 57)) ) GROUP BY TaskStatus order by TaskStatus DESC