Is the following possible:
EXEC sp_Edu3_DeleteTreeStructure (SELECT TreeStructureId FROM TreeStructures)
The SP normally takes one argument. What I want is that the SP is executed for each TreeStructureId found by the Query.
thx, Lieven Cardoen
Is the following possible:
EXEC sp_Edu3_DeleteTreeStructure (SELECT TreeStructureId FROM TreeStructures)
The SP normally takes one argument. What I want is that the SP is executed for each TreeStructureId found by the Query.
thx, Lieven Cardoen
You can use a CURSOR to do this.
DECLARE @treeStructureId int
DECLARE TreeStructureCursor CURSOR FOR
SELECT
TreeStructureId
FROM
TreeStructures
OPEN TreeStructureCursor
FETCH NEXT FROM TreeStructureCursor
INTO @treeStructureId
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC sp_Edu3_DeleteTreeStructure(@treeStructureId)
FETCH NEXT FROM TreeStructureCursor
INTO @treeStructureId
END
CLOSE TreeStructureCursor
DEALLOCATE TreeStructureCursor