ReportingAnalyst
MIS
What is the syntax error near the WITH statement?
Thanks.
Error I get is:
Incorrect syntax near the keyword 'with'.
Thanks.
Code:
with organization (depth, emp, boss, chain)
as
( select 1 as depth,
emp,
boss,
cast(rtrim(emp) as varchar (400))
from tree
where boss is null
union all
select a.depth + 1 as depth,
b.emp,
b.boss,
cast (a.chain + ', ' + rtrim(b.emp) as varchar(400))
from organization a
inner join tree b
on a.emp = b.boss
)
Error I get is:
Incorrect syntax near the keyword 'with'.