Msg 208, Level 16, State 1, Line 2
Invalid object name 'h.codoptima'.
:(
Código SQL:
Ver originalSELECT h.hora,h.marca,h.codoptima,h.target,P.CODOPTIMA,O.CODIGO,p.hora,p.peso,p.vaso,p.fecha,o.linea,o.tubo INTO #temp
FROM pesos AS p, optimas AS o,htargets AS h, h.codoptima AS codoptimaT
WHERE o.codigo = p.codOptima AND o.linea = 'L01S'
AND o.tubo LIKE '%' AND p.fecha BETWEEN '2010-06-18 09:00' AND '2010-06-18 09:30'
AND p.hora='9:00 - 9:30' AND h.codoptima = o.codigo AND h.hora='9:00 - 9:30'
SELECT *,(SELECT COUNT(1)total FROM #temp) FROM #temp