I need help with a stored procedure that allows me to delete a column in the usuarios
table and when this column is deleted, delete all the data where it is used as primary key its id
, the table that inherits from usuarios
is facturas
and this invoice has a detail invoice det_factura
inheriting the primary key from facturas
.
GO
CREATE PROCEDURE sp_eliminarusuario
@iduser int
AS
BEGIN
DELETE det_facturas FROM facturas f, det_facturas d, usuarios u WHERE
f.idfactura = d.idfactura and f.idusuario=u.idusuario
DELETE facturas FROM facturas f, usuarios u where f.idusuario=u.idusuario
DELETE FROM usuarios WHERE idusuario = @idusers
END
This procedure removes all the data in facturas
as in det_facturas
as it could solve it