Ver Mensaje Individual
  #6 (permalink)  
Antiguo 07/06/2005, 15:11
Guillian lópez
 
Fecha de Ingreso: marzo-2005
Ubicación: Caracas; Junquito
Mensajes: 1
Antigüedad: 20 años
Puntos: 0
A Ver Si Te Sirve

HOLA ME PARESE QUE SI EMPIEZAS CON "IF" DEBES SEGUIR CON CON "ELSE", EN CASO DE QUE AYA OTRA CONDICION, Y PARA TERMINAR EL CICLO DE CONDICIONES DEBES TERMINAR CON "END IF"

AL NO CUMPLIRSE LA PRIMERA CONDICION,SE COMPLIRIA LA OTRA O PUEDE DARSE EL CASO DE Q NINGUNA SE CUMPLA Y SE CULMINA EL CICLO CON "END IF"

SI NO TE RESULTA DISCULPA POR NO PODER AYUDARTE HICE LO QUE PUDE...






Cita:
Iniciado por reneac79
Q onda? como estan?

Pues yo estoy un tanto mal, he estado buscando alguna manera de utilizar IF en procedimientos Almacenados pero creo q lo estoy haciendo mal

de Igual manera estuve buscando algo asi como un switch o case y tampoco encontre nada,

debe haber alguna manera de hacerlo, no puedo creer q sql server no haya contemplado esta situación, o si?

pongo algo de mi SP pa ver si pueden ayudarme, por favor

''''''''''''

CREATE PROCEDURE [sp_repVentaVendRSuc1]
(
@fechaI [nvarchar] (10),
@fechaF [nvarchar] (10),
@sucursal [nvarchar] (2)

)
AS
create table #temp
(
vendedor nvarchar (5),
nomvendedor nvarchar (150),
totpzas float,
totkgs float,
importe float,
contado float,
credito float
)

IF @SUCURSAL = '1'

INSERT INTO #temp select * from tbl1 where fecha between convert(datetime,@fechaI,103) and convert(datetime,@fechaF,103) and tbl1.ncvesuc = @sucursal

INSERT INTO #temp select * from tbl2 where fecha between convert(datetime,@fechaI,103) and convert(datetime,@fechaF,103) and tbl1.ncvesuc = @sucursal

INSERT INTO #temp select * from tbl3 where fecha between convert(datetime,@fechaI,103) and convert(datetime,@fechaF,103) and ncvesuc = @sucursal


'''''''''''''''''''''''''''''''''''''''''''''''''' '''''' aki quiero q termine el primer if
IF @SUCURSAL <> '1'

INSERT INTO #temp select * from tbl1 where fecha between convert(datetime,@fechaI,103) and convert(datetime,@fechaF,103) and tbl1.ncvesuc = @sucursal

INSERT INTO #temp select * from tbl2 where fecha between convert(datetime,@fechaI,103) and convert(datetime,@fechaF,103) and tbl1.ncvesuc = @sucursal

INSERT INTO #temp select * from tbl3 where fecha between convert(datetime,@fechaI,103) and convert(datetime,@fechaF,103) and ncvesuc = @sucursal


'''''''''''''''''''''''''''''''''''''''''''''''''' '''''' aki quiero q termine el segundo if

SELECT * from #temp
group by nomvendedor,vendedor
order by vendedor

'''''''''''''

Como cierro el if,o q puedo ahcer en vez del if?

espero q me puedan ayudar !!!

O si no se pude por favor, repondan, gracias...