Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/01/2007, 11:55
jesusito
 
Fecha de Ingreso: junio-2004
Mensajes: 170
Antigüedad: 19 años, 10 meses
Puntos: 0
Pregunta retornar un mensaje en SP

Hola tengo el siguiente procedimiento almacenado:

create procedure sp_consulta_existencia (
@rutempresa varchar(15),
@Rut_Empleado varchar(8000),
@idturno int

)


as


DECLARE @Empleados varchar(8000)
DECLARE @Rut varchar(20)
DECLARE @Posicion int
Declare @entidad varchar(10)
DECLARE @msg INT


SET @Empleados = @Rut_Empleado+','
set @msg=1

WHILE patindex('%,%' , @Empleados) <> 0
BEGIN
SELECT @Posicion = patindex('%,%' , @Empleados)
SET @Rut = left(@Empleados, @Posicion - 1)
SELECT @Empleados = stuff(@Empleados, 1, @Posicion, '')

SELECT @ENTIDAD=Id_Entidad from EMPLEADOS where rut_empleado=@rut

if @entidad is null or @entidad=''
begin
SET @Entidad='1'
end
BEGIN Transaction


Select t.Id_Turno from Empleados as e
Inner Join Turno_Empleado as t On e.rut_empleado=T.rut_Empleado
where e.rut_Empresa=@rutEmpresa and e.estado='0' and id_Turno=@idturno and t.rut_empleado=@Rut
Commit Transaction

if @idturno = Id_Turno
begin
set @msg = 1
end

if @idturno != Id_Turno
begin
set @msg = 0
end


END


GO


pero me retorna un mensaje para todos los rut entregados con parametro en la variable Rut_Empleado, como lo tengo q hacer para q me retorne un mensaje para cada uno?


saludos