I have this procedure that I use to choose between one type of user or another for a login window, I get syntax error but I can not find the logic failure.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE Sp_Login
-- Add the parameters for the stored procedure here
@usuario varchar(50),
@password varchar(50),
@id int output,
@inst varchar(10)output
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
@id = (SELECT Id_Usuario FROM Usuarios WHERE CodigoUsuario = @usuario AND Password = @password)
if @id!=-1
begin
@inst = 'true'
print 'true'
end
else
begin
@id =(SELECT Id_Administrador FROM Administradores WHERE Usuario=@usuario AND Password = @password)
if @id!=-1
begin
@inst = 'false'
print 'false'
end
else
begin
@inst = 'none'
print 'none'
end
end
END
GO
UserCode and User never have the same name
The errors of the procedure are in the Insert statements, in @id and @inst