Answer the question
In order to leave comments, you need to log in
How to rewrite with as where recursion is used?
there is such a code
WITH ParentDocs AS
(
SELECT doc.DocId, doc.ParentDocGUID, doc.doc_guid, doc.db_id, 0 AS doc_level, doc.DocId
FROM TV_DocsTableInternet doc
UNION ALL
SELECT e.DocId, e.ParentDocGUID, e.DocGUID, e.db_id, doc_level + 1, d.Cheque_docid as Cheque_docid
FROM TV_DCT_Docs e
JOIN ParentDocs d
ON e.db_id = d.db_id
AND e.doc_guid = d.parent_doc_guid
AND e.doc_guid <> d.doc_guid
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question