whatsthehampton
Programmer
Dear all,
From my web app. I am trying to cascade delete entries that are in a self referencing table.
This cte brings back the id's I need
--------------------------------------
declare @idx int
set @idx=1; -- need to pass in the variable here
WITH OrganisationChart (Id, parentid)
AS
(SELECT Id, parentid
FROM ecocv_tbl_sitecontent
WHERE id =@idx
UNION ALL
SELECT sc.Id, sc.parentid
FROM ecocv_tbl_sitecontent sc INNER JOIN OrganisationChart
ON sc.parentid = OrganisationChart.Id)
SELECT id FROM OrganisationChart
--------------------------------------
But I need to access the returned IDs in my delete stored procedure somehow but am stuck.
How can I loop through the return vaules and delete each one please?
Cheers,
J
ToDo....
From my web app. I am trying to cascade delete entries that are in a self referencing table.
This cte brings back the id's I need
--------------------------------------
declare @idx int
set @idx=1; -- need to pass in the variable here
WITH OrganisationChart (Id, parentid)
AS
(SELECT Id, parentid
FROM ecocv_tbl_sitecontent
WHERE id =@idx
UNION ALL
SELECT sc.Id, sc.parentid
FROM ecocv_tbl_sitecontent sc INNER JOIN OrganisationChart
ON sc.parentid = OrganisationChart.Id)
SELECT id FROM OrganisationChart
--------------------------------------
But I need to access the returned IDs in my delete stored procedure somehow but am stuck.
How can I loop through the return vaules and delete each one please?
Cheers,
J
ToDo....