Gracias por el apoyo, ya me quedo, me quedo asi:
Código SQL:
Ver originalSET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Franco Luis Roberto>
-- Create date: <05-Sep-2012>
-- Description: <Show information of all lines,>
-- =============================================
ALTER PROCEDURE Report_All_Lines
@codigo nvarchar(500),
@StartDate nvarchar (50),
@EndDate nvarchar(81)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @MySQL VARCHAR(2000)
SET @MySQL='SELECT dbo.Optimas.Linea, dbo.pesos.Peso,dbo.htargets.Target, dbo.HTargets.Marca, dbo.pesos.Vaso, dbo.Optimas.Tubo, dbo.pesos.Hora from pesos inner join Optimas on optimas.codigo = pesos.codoptima inner join htargets on optimas.codigo = htargets.codoptima where optimas.codigo in('+@codigo+') and dbo.pesos.fecha >= '''+@StartDate+''' and dbo.pesos.fecha <= '''+@EndDate+''' and dbo.htargets.Fecha >= '''+@StartDate+''' and dbo.htargets.fecha <= '''+@EndDate+'''order by linea'
EXEC(@MySQL)
END
GO
Saludos