Código:
Microsoft SQL Server Management Studio 9.00.3042.00
Microsoft Analysis Services Client Tools 2005.090.3042.00
Microsoft Data Access Components (MDAC) 2000.086.3959.00 (srv03_sp2_rtm.070216-1710)
Microsoft MSXML 2.6 3.0 6.0
Microsoft Internet Explorer 6.0.3790.3959
Microsoft .NET Framework 2.0.50727.3615
Operating System 5.2.3790
Ya intente hacer el Inner join pero me da error:
Código SQL:
Ver originalUSE [wasp]
GO
/****** Object: StoredProcedure [dbo].[report] Script Date: 02/22/2011 09:47:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[report]
@finicio datetime,
@ffin datetime,
@linea nvarchar(5),
@tubo nvarchar(5),
@hora nvarchar(15) AS
BEGIN
SET Nocount ON
SELECT o.Linea,o.Tubo,h.Marca,h.Target,p.Peso,p.Vaso,O.Codigo,p.Hora,p.Fecha
INTO #checho
FROM pesos AS p, optimas AS o,htargets AS h
INNER JOIN pesos ON pesos.codoptima = codiogo.optmimas
WHERE o.codigo = p.codOptima AND o.linea = @linea
AND o.tubo = @tubo AND p.fecha >=@finicio AND p.fecha<@ffin
AND h.fecha >=@finicio AND h.fecha<@ffin
AND p.hora= @hora AND h.codoptima = o.codigo AND h.hora= @hora
SELECT *,(SELECT COUNT(1)total FROM #checho) AS Totality FROM #checho ORDER BY fecha
END
Dejo uina captura de pantalla de mis tablas