How to control string space in SQL Server?
I change this开发者_如何学C :
SELECT
FLAG, DESCRIPTION
FROM MYTABLE AS A
WHERE
((A.FLAG = 0 AND A.DESCRIPTION IS NULL)
OR (A.FLAG != 0 AND A.DESCRIPTION IS NULL))
with this :
SELECT
FLAG, DESCRIPTION
FROM MYTABLE AS A
WHERE
((A.FLAG = 0 AND
CASE LTRIM(RTRIM(A.DESCRIPTION))
WHEN ‘’ THEN NULL
ELSE A.DESCRIPTION
END IS NULL)
OR
(A.FLAG != 0 AND
CASE LTRIM(RTRIM(A.DESCRIPTION))
WHEN ‘’ THEN NULL
ELSE A.DESCRIPTION
END IS NULL)
)
but it gives error about 'case when'. How to solve this? thanks in advance.
You have two CASE and only one corresponding END. Each of the CASE should be closed by it's own END.
EDIT: You updated the query in question. You new query is fine, it executes here with no problem. If it gives error on your end, then there is something else you are not telling us in the problem description.
精彩评论