Doubt about stored procedure that updates data [closed]

0

I am creating a stored procedure that updates me the data, at the moment of compiling it I am given this error "Incorrect syntax near the keyword 'SET'".

 CREATE PROCEDURE SP_Arriendo_Marcas_U
 @Nombre_Marca VARCHAR(25),
@cMarca SMALLINT
AS
DECLARE @salida nvarchar(30),

-- Validación Mayuscula
SET @Nombre_Marca = UPPER(@Nombre_Marca)
IF NOT exists (
SELECT cMarca
FROM dbo.Arriendo_Marcas
WHERE Nombre_Marca LIKE @Nombre_Marca
)
BEGIN
  -- Actualizar registro
  UPDATE Arriendo_Marcas 
  SET Nombre_Marca=@Nombre_Marca WHERE cMarca=@cMarca

  -- generar mensaje de salida
  SET @salida = 'Registro Actualizado: ' + CONVERT(varchar(10), SCOPE_IDENTITY())
END
  ELSE
-- generar mensaje de salida
SET @salida = 'Registro ya existe'
    
asked by Daniela 31.10.2018 в 21:00
source

1 answer

2

Your drawback is in the declaration of the variable, you are missing a ",".

DECLARE @salida nvarchar(30), -- Aquí!!

Delete it and try it. Greetings.

    
answered by 31.10.2018 / 21:15
source