use EnVisage
go

declare capdelete cursor for select parentid from Scenario where type = 5
declare @projectId uniqueidentifier
open capdelete
fetch next from capdelete into @projectId
while @@FETCH_STATUS = 0
begin
	delete from ProjectAccess where ProjectId = @projectId
	exec sp_DeleteProject @projectId
	fetch next from capdelete into @projectId
end
close capdelete
deallocate capdelete
