Me da error,
http://ompldr.org/vNzFvYw
Código SQL:
Ver originalALTER PROCEDURE [dbo].[monitor2]
@fecha datetime,
@linea nvarchar(5),
@hora nvarchar(15) AS
DECLARE @reg INT
BEGIN
SET Nocount ON
SELECT @reg = COUNT(1),h.hora AS hora1,h.marca,h.target,h.fecha AS hfecha,p.hora,p.peso,p.fecha,o.linea
FROM optimas AS o
INNER JOIN pesos AS p ON o.codigo = p.codoptima
INNER JOIN htargets AS h ON o.codigo = h.codoptima
WHERE o.linea = @linea
AND p.fecha >= @fecha AND h.fecha >= @fecha
AND p.hora = @hora AND h.hora = @hora
ORDER BY fecha
SET @reg = @@rowcount
SELECT top 1 h.hora AS hora1,h.marca,h.target,h.fecha AS hfecha,p.hora,p.peso,p.fecha,o.linea, @reg AS 'RowsReturned'
FROM optimas AS o
INNER JOIN pesos AS p ON o.codigo = p.codoptima
INNER JOIN htargets AS h ON o.codigo = h.codoptima
WHERE o.linea = @linea
AND p.fecha >= @fecha AND h.fecha >= @fecha
AND p.hora = @hora AND h.hora = @hora
--SELECT top 1 @reg AS 'RowsReturned'
--SELECT @@rowcount AS 'RowsReturned'
--SELECT TOP 1 *,(SELECT count(1)total FROM #temporal1) as totality from #temporal1
END