I have the following query: Realize a trigger of type update in the table "x" and verify if the new data of the name and appelled already exist, if they do not change, otherwise modify the information.
create trigger ActualizarInfo
on tabla1
for update
as
begin
declare @nombre varchar(30)
@apellido varchar (30)
if exists (name=@nombre and lastname=@apellido)
print 'usuario existente, no modificar'
end
else
begin
update tabla1
set name=@nombre
set lastname=@apellido
end
My question is: if I can handle my variables that I declare (@ name, @ last name)? or as valid if they exist or not?