Создать пользовательскую функцию:
CREATE FUNCTION fnBuildUrl (
@page varchar(100),
@emp_value varchar(100)
)
RETURNS VARCHAR(1000)
AS
BEGIN
DECLARE @url varchar(1000)
SELECT @url = CASE WHEN LEFT(@page, 1) = '/' THEN
@page + '(' + @emp_value + ')'
ELSE
CASE WHEN CHARINDEX('?', @page) > 0 THEN
@page + '&Id=' + @emp_value + '&fromSSR=T'
ELSE @page + '?Id=' + @emp_value + '&fromSSR=T' END
END
RETURN @url
END
GO
Тогда позвони в свой SELECT
:
SELECT emp.Id,
CASE WHEN tab.NOT_CH_APPROVAL = 'T' THEN dbo.fnBuildUrl(tab.PAGE, emp.EMP_VALUE) + '&userCanApprove=1'
ELSE dbo.fnBuildUrl(tab.PAGE, emp.EMP_VALUE) END AS RedirectURL
FROM EMPLOYEES emp
LEFT OUTER JOIN CATEGORY tab
ON tab.EMP_ID = emp.Id
AND tab.Id = 19