Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/11/2007, 09:08
Avatar de viqtor
viqtor
 
Fecha de Ingreso: noviembre-2007
Ubicación: Donde estoy?
Mensajes: 49
Antigüedad: 17 años
Puntos: 0
Problemas Al Declarar Un Query De Mssql En Php

Este es el query que quiero usar en Php, y nose como declarar las variables de sql, para que php lo entienda, espero su ayuda.

set dateformat dmy;
declare @FI smalldatetime
declare @FF smalldatetime
declare @vendedor char(5)
declare @producto char (13)
set @FI = '01/10/2007 00:00'
set @FF = '22/11/2007 23:59'
set @vendedor = '15'
set @producto = '1'

SELECT C.cod_cte, C.razon_social,
isnull((select top 1 fecha
from entysal where status <> 'C' and fecha between @FI and @FF and cod_cte = C.cod_cte
and vendedor = @vendedor and cod_prod = @producto and transaccion in ('36','37','38')
order by fecha desc),'') as ultima_venta,
isnull((select top 1 fecha
from mpedcte where status <> 'C' and fecha between @FI and @FF and cod_cte = C.cod_cte
and vendedor = @vendedor and cod_prod = @producto and transaccion = '31'
order by fecha desc),'') as ultima_pedido,
isnull((select sum(cantidad) from entysal where folio in
(select top 1 folio
from entysal where status <> 'C' and fecha between @FI and @FF and cod_cte = C.cod_cte
and vendedor = @vendedor and cod_prod = @producto and transaccion in ('36','37','38')
order by fecha desc)),0.0) as cantidad_venta,
isnull((select sum(cantidad_pedida) from mpedcte where folio in
(select top 1 folio
from mpedcte where status <> 'C' and fecha between @FI and @FF and cod_cte = C.cod_cte
and vendedor = @vendedor and cod_prod = @producto and transaccion = '31'
order by fecha desc)),0.0) as cantidad_pedido,
isnull((select status from pedcte where folio in
(select top 1 folio
from mpedcte where status <> 'C' and fecha between @FI and @FF and cod_cte = C.cod_cte
and vendedor = @vendedor and cod_prod = @producto and transaccion = '31'
order by fecha desc)),'') as status_pedido
FROM CLIENTES C
where vendedor = @vendedor

MUACHAS GRACIAS