I have a little problem, how could I improve my QUERY, I want to delete multiple rows from multiple tables using the foreign key with this :
CREATE PROCEDURE SCOUTL.DeleteRegistroUsuario(@ID INT)
AS
BEGIN
DECLARE @Evidencia AS UNIQUEIDENTIFIER;
SET @Evidencia =
(
SELECT e.IdEvidenciaPorPractica
FROM SCOUTL.EvidenciaPorPractica e
INNER JOIN SCOUTL.RegistroUsuario r ON e.IdEvidenciaPorPractica = r.IdEvidenciaPorPracticaFK
WHERE r.IdRegistroUsuario = @ID
);
DELETE FROM SCOUTL.RegistroUsuario
WHERE IdRegistroUsuario = @ID;
DELETE FROM SCOUTL.EvidenciaPorPractica
WHERE IdEvidenciaPorPractica = @Evidencia;
END;
But, when i execute this query, return this:
Incorrect syntax near @ID
Please, I need corrections