Case Format
torsten.strauss
Posts: 271 Silver 3
in SQL Prompt
Hi !
The following code is formatted like this
[code]
co2.COMPONENT_ID
, co2.COMPONENT_TYPE
, CASE WHEN co2.COMPONENT_TYPE <> 21 THEN NULL ELSE co2.PARENT_ID END AS PARENT_ID
FROM
SENTOSA.COMPONENT_HIERARCHY AS ch
CROSS APPLY dbo.ListAncestors(ch.NodePath_COMPONENT_ID) AS A
INNER JOIN
SENTOSA.COMPONENT_HIERARCHY AS co2
ON
A.node = co2.NodePath_COMPONENT_ID;
, co2.COMPONENT_TYPE
, CASE WHEN co2.COMPONENT_TYPE <> 21 THEN NULL ELSE co2.PARENT_ID END AS PARENT_ID
FROM
SENTOSA.COMPONENT_HIERARCHY AS ch
CROSS APPLY dbo.ListAncestors(ch.NodePath_COMPONENT_ID) AS A
INNER JOIN
SENTOSA.COMPONENT_HIERARCHY AS co2
ON
A.node = co2.NodePath_COMPONENT_ID;
[/code]
The case is not aligned and a there is a tab after the the CASE which makes no sense !
Thanks for fixing this!
Torsten
MVP
Tagged:
Answers
co2.COMPONENT_ID
, co2.COMPONENT_TYPE
, CASE WHEN co2.COMPONENT_TYPE <> 21 THEN NULL ELSE co2.PARENT_ID END AS PARENT_ID
FROM
SENTOSA.COMPONENT_HIERARCHY AS ch
CROSS APPLY dbo.ListAncestors(ch.NodePath_COMPONENT_ID) AS A
INNER JOIN
SENTOSA.COMPONENT_HIERARCHY AS co2
ON
A.node = co2.NodePath_COMPONENT_ID;
Style is attached...
could there be some strange characters added in your query? If you copy paste in notepad and then paste back?