I have to prevent a column from duplicating so I made this Stored Procedure
CREATE PROCEDURE [dbo].Agregar_Personal
@nom varchar(20),
@apll varchar(20),
@tel int,
@dep int,
@sal float
AS
IF dbo.UnicoApellido(@apll) = 0
INSERT INTO Personal (Nombre,Apellido,Telefono,Departamento,Salario)
VALUES (@nom,@apll,@tel,@dep,@sal)
RETURN 0;
ELSE
RETURN 1;
(the function dbo.UnicoApellido returns 0 if the value is repeated in the table)
the issue here is that I'm getting an error in ELSE, saying that the syntax is wrong. Can anyone tell me what is the error, or if there's another way to prevent duplications when performing an INSERT?
Aucun commentaire:
Enregistrer un commentaire