Ver Mensaje Individual
  #5 (permalink)  
Antiguo 05/09/2012, 12:23
th3r0rn
 
Fecha de Ingreso: noviembre-2007
Mensajes: 504
Antigüedad: 16 años, 5 meses
Puntos: 2
Respuesta: Store procedura como consultyar where in varios valores

Gracias por el apoyo, ya me quedo, me quedo asi:
Código SQL:
Ver original
  1. SET ANSI_NULLS ON
  2. GO
  3. SET QUOTED_IDENTIFIER ON
  4. GO
  5. -- =============================================
  6. -- Author:      <Franco Luis Roberto>
  7. -- Create date: <05-Sep-2012>
  8. -- Description: <Show information of all lines,>
  9. -- =============================================
  10. ALTER PROCEDURE Report_All_Lines
  11.    
  12. @codigo nvarchar(500),
  13. @StartDate nvarchar (50),
  14. @EndDate nvarchar(81)  
  15.  
  16. AS
  17. BEGIN
  18.     -- SET NOCOUNT ON added to prevent extra result sets from
  19.     -- interfering with SELECT statements.
  20.     SET NOCOUNT ON;
  21.  
  22.   DECLARE  @MySQL VARCHAR(2000)
  23. 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'
  24.  EXEC(@MySQL)
  25.  
  26. END
  27. GO
Saludos