I need help in sql recursive query, for example purpose i m providing sample table with insert scriptCREATE TABLE Details(parentid varchar(10), DetailComponent varchar(10) , DetailLevel int)GOINSERT INTO Details SELECT '','7419-01',0 union allSELECT '7419-01','44342-00',1 union allSELECT '7419-01','45342-00',1 union allSELECT '7419-01','46342-00',1 union allSELECT '7419-01','47342-00',1 union allSELECT '7419-01','48342-00',1 union allSELECT '7419-01','49342-00',1 union allSELECT '7419-01','50342-00',1 union allSELECT '50342-00','51342-00',2 union allSELECT '7419-01','52342-00',1 union allSELECT '52342-00','54342-00',2 union allSELECT '54342-00','54442-00',3 union allSELECT '54342-00','54552-00',3 union allSELECT '54552-00','R34S-54',4 union allSELECT '54552-00','R123-54',4 union allSELECT '54552-00','R111-54',4 union allSELECT 'R111-54','R222-54',5 union allSELECT 'R222-54','52342-00',6 union allSELECT '7419-01','TEST34-00',1 union allSELECT 'TEST34-00','445334-00',2 union allSELECT '445334-00','52342-00',3 union allSELECT '7419-01','1111-00',1 union allSELECT '7419-01','1111-00',1 union allSELECT '1111-00','52342-00',2 GOSELECT * FROM DetailsFrom the above table data i want a search query , for example if I search data with "52342-00" I want output to be below format using CTE.NULL,'7419-01',0'7419-01','52342-00',1'7419-01','52342-00',1'52342-00','54342-00',2'54342-00','54552-00',3'54552-00','R111-54',4'R111-54','R222-54',5'R222-54','52342-00',6thanks
↧