Insert

29/10/2003 - 01:57 por Julio rodriguez | Informe spam
Hola Grupo

Como puedo crear un trigger para que se me dispare cuando se instroduzca
una fecha en un campo y hacer un insert de esta fecha en otro campo.

Preguntas similare

Leer las respuestas

#1 Isaías
29/10/2003 - 02:26 | Informe spam
¿Existe alguna razon para utilizar Trigger?

CREATE PROCEDURE PR_MYINSERT

AS

INSERT INTO MYTABLA VALUES(...)
IF @@ROWCOUNT > 0
INSERT INTO MYOTRA TABLA VALUES(..)


Saludos.
Respuesta Responder a este mensaje
#2 Julio rodriguez
29/10/2003 - 02:38 | Informe spam
Quiero hacer lo siguiente a ver si me ayudan:
Aqui estoy haciendo un select de un campo llamado fecha para extraer el mes
a partir de la fecha que se encuentre en el campo
Ahora quiero hacer un insert del select en un campo llamado Mes.

quiero hacer esto para que cuando se inserte una fecha en el campo fecha me
haga un insert del mes automaticamente.



select case datepart(mm,fecha)
when '01' then 'Enero'
when '02' then 'Febrero'
when '03' then 'Marzo'
when '04' then 'Abrir'
when '05' then 'Mayo'
when '06' then 'Junio'
when '07' then 'Julio'
when '08' then 'Agosto'
when '09' then 'Septiembre'
when '10' then 'Octubre'
when '11' then 'Noviembre'
when '12' then 'Diciembre'
end
as mes
from prueba







"Isaías" wrote in message
news:109d01c39dbb$ab77b4a0$
¿Existe alguna razon para utilizar Trigger?

CREATE PROCEDURE PR_MYINSERT

AS

INSERT INTO MYTABLA VALUES(...)
IF @@ROWCOUNT > 0
INSERT INTO MYOTRA TABLA VALUES(..)


Saludos.
Respuesta Responder a este mensaje
#3 Isaías
29/10/2003 - 03:29 | Informe spam
Aqui te mando una prueba, checala:

DROP TABLE TIRAR
CREATE TABLE TIRAR (MYFecha datetime, MyMes AS
case datepart(mm,MYFecha)
when '01' then 'Enero'
when '02' then 'Febrero'
when '03' then 'Marzo'
when '04' then 'Abrir'
when '05' then 'Mayo'
when '06' then 'Junio'
when '07' then 'Julio'
when '08' then 'Agosto'
when '09' then 'Septiembre'
when '10' then 'Octubre'
when '11' then 'Noviembre'
ELSE 'Diciembre' END)
INSERT INTO TIRAR VALUES(getdate())
SELECT * FROM TIRAR
MYFecha
MyMes
-
2003-10-28 20:25:47.350 Octubre

(1 row(s) affected)
Respuesta Responder a este mensaje
#4 Julio
29/10/2003 - 14:15 | Informe spam
Gracias Isaias por la ayuda pero ahora tengo un problema que se no se hace
un insert para el campo Myfecha me pone el campo Mymes como Null y si se
hace un insert del formato de la fecha equivocado se hace la transacion pero
me pone el campo MyFecha null

Gracias

"Isaías" wrote in message
news:08e901c39dc4$7d3c98e0$
Aqui te mando una prueba, checala:

DROP TABLE TIRAR
CREATE TABLE TIRAR (MYFecha datetime, MyMes AS
case datepart(mm,MYFecha)
when '01' then 'Enero'
when '02' then 'Febrero'
when '03' then 'Marzo'
when '04' then 'Abrir'
when '05' then 'Mayo'
when '06' then 'Junio'
when '07' then 'Julio'
when '08' then 'Agosto'
when '09' then 'Septiembre'
when '10' then 'Octubre'
when '11' then 'Noviembre'
ELSE 'Diciembre' END)
INSERT INTO TIRAR VALUES(getdate())
SELECT * FROM TIRAR
MYFecha
MyMes
-
2003-10-28 20:25:47.350 Octubre

(1 row(s) affected)
Respuesta Responder a este mensaje
#5 Julio
29/10/2003 - 14:31 | Informe spam
Quise decir

que cuando no se hace
un insert para el campo Myfecha me pone el campo Mymes como Null y si se
hace un insert del formato de la fecha equivocado (28/07/76) me pone el
campo MyFecha null

"Julio" wrote in message
news:%23Dt$
Gracias Isaias por la ayuda pero ahora tengo un problema que se no se hace
un insert para el campo Myfecha me pone el campo Mymes como Null y si se
hace un insert del formato de la fecha equivocado se hace la transacion


pero
me pone el campo MyFecha null

Gracias

"Isaías" wrote in message
news:08e901c39dc4$7d3c98e0$
> Aqui te mando una prueba, checala:
>
> DROP TABLE TIRAR
> CREATE TABLE TIRAR (MYFecha datetime, MyMes AS
> case datepart(mm,MYFecha)
> when '01' then 'Enero'
> when '02' then 'Febrero'
> when '03' then 'Marzo'
> when '04' then 'Abrir'
> when '05' then 'Mayo'
> when '06' then 'Junio'
> when '07' then 'Julio'
> when '08' then 'Agosto'
> when '09' then 'Septiembre'
> when '10' then 'Octubre'
> when '11' then 'Noviembre'
> ELSE 'Diciembre' END)
> INSERT INTO TIRAR VALUES(getdate())
> SELECT * FROM TIRAR
> MYFecha
> MyMes
> -
> 2003-10-28 20:25:47.350 Octubre
>
> (1 row(s) affected)


Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaSiguiente Respuesta Tengo una respuesta
Search Busqueda sugerida