Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Tengo un error a la hora de probar el store procedure. Sin embargo desde el principio se declaro como int. (Translates to - "I have an error when testing the store procedure. However, from the beginning it was declared as int."

What I have tried:

--Validar Usuario--
CREATE PROCEDURE SP_USUARIOS
@rol_id int, 
@id_usuario int, 
@clave varchar(150)
AS
BEGIN
	SELECT USUARIOS.id_usuario, USUARIOS.primer_nombre,
	USUARIOS.segundo_nombre, USUARIOS.primer_apellido,
	USUARIOS.segundo_apellido, USUARIOS.tipo_identificacion_id, 
	USUARIOS.correo, USUARIOS.municipio_id, 
	USUARIOS.celular, USUARIOS.direccion,
	USUARIOS.sede_id, USUARIOS.rol_id, 
	USUARIOS.clave, ROLES.rol
	FROM USUARIOS INNER JOIN
	ROLES ON USUARIOS.rol_id = ROLES.id_rol
	WHERE
	USUARIOS.rol_id='@rol_id'
	and USUARIOS.id_usuario='@id_usuario'
	and USUARIOS.clave='@clave'
	and USUARIOS.estado=1
END

execute SP_USUARIOS 1, 1023465198, 1234.12
Posted
Updated 10-Jun-23 0:14am
v2

1 solution

Remove the quotes if you want to use variables:
SQL
WHERE
USUARIOS.rol_id=@rol_id
and USUARIOS.id_usuario=@id_usuario
and USUARIOS.clave=@clave
and USUARIOS.estado=1
Quotes delimit string literals, so you are trying to compare an integer with the string '@rol_id' so SQL tries to convert it to an integer and fails.
 
Share this answer
 
v2
Comments
Richard MacCutchan 10-Jun-23 7:42am    
That's another one ... I think you have a stalker. Not me, I just happened to be passing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900