SQL - URGENTISIMO S O C O R R O CON UN INSERT¡¡¡

 
Vista:

URGENTISIMO S O C O R R O CON UN INSERT¡¡¡

Publicado por VIRFEL (11 intervenciones) el 21/11/2002 19:11:21
HOLA TENGO UN PROBLEMA NO SE COMO HACER UN INSERT DE ESTOS DATOS.

TENGO UN S.PROCEDURE

CREATE PROCEDURE Calcula_costo_NC AS
DECLARE
@COSTO

SELECT @COSTO=I.ilscst
from tabla R,Inv_Costos I
where substring(R.codigocambio,1,6)=substring(I.codigocambio,1,6)
GO

CUANDO EJECUTO EL S.P ME MUESTRA TODOS LOS COSTOS DONDE EL ALIAS R ES IGUAL AL ALIAS I.


PERO CUANDO HAGO UN INSERT SOLO ME INSERTA EL ULTIMO VALOR QUE LEE Y NO ME INSERTA LOS DEMAS DATOS????.

INSERT INTO TABLA2
VALUES(@COSTO)

PORQUE SOLO ME INSERTA EL ULTTIMO VALOR SIENDO QUE SON MAS DE 10 VALORES LOS QUE CUMPLEN LA CONDICION?

ALGUIEN PUEDE AYUDARME.

Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:URGENTISIMO S O C O R R O CON UN INSERT¡¡¡

Publicado por Carlos Alberto (8 intervenciones) el 22/11/2002 17:32:14
Es que la variable q usas no puede almacenar todos los datos de un select solamente alamcena el ultimo, Si quieres insertar todas las filas q cumplen tu condicion realiza un cursor y en el bucle realizas la inservion uno por uno o puedes realizar un insert into de copia masiva.
Espero te auyde....
---------------------------------
Super Saludos,
C.U.
----------------------------------
Analisis y Programación
Sistemas
Trading Fashion Line S.A.
Topy Top S.A.
Telf.: 426-0086
428-7738
Cel. : 918-7311
Lima-Perú

Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:URGENTISIMO S O C O R R O CON UN INSERT¡¡¡

Publicado por Isaías Islas (5072 intervenciones) el 25/11/2002 21:44:13
Creo que debe ser así

INSERT INTO MyTabla (MyColumna)
SELECT I.ilscst
from tabla R,Inv_Costos I
where substring(R.codigocambio,1,6)=substring(I.codigocambio,1,6)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar