Good evening guys, I need to make sure that the address and phone columns are null, in case an error message is returned, otherwise the operation will take effect. my code looks like this:
CREATE TRIGGER VERIFICA
ON cliente
INSTEAD OF INSERT AS
BEGIN
DECLARE
@NOME VARCHAR(50),
@TELEFONE VARCHAR(12),
@ENDERECO VARCHAR (100)
SELECT @NOME = NOME FROM inserted
SELECT @TELEFONE = TELEFONE FROM inserted
SELECT @ENDERECO = ENDERECO FROM inserted
IF @telefone is not null and @endereco is not null
begin
RAISERROR ('Campos nulos', 11,1);
end
ELSE
INSERT INTO cliente (nome, telefone, endereco) VALUES (@NOME, @TELEFONE, @ENDERECO);
END