· 8 years ago · Dec 25, 2017, 11:54 AM
1if exists (select 1
2 from sysobjects c
3 join sysconstraints s on (s.constrid = c.id and s.tableid = object_id('aumen_masivo_det_archivo'))
4 where name = 'FK_AUMEN_MA_REF_estados' and type = 'RI')
5 alter table aumen_masivo_det_archivo
6 drop constraint FK_AUMEN_MA_REF_estados
7go
8
9if exists (select 1
10 from sysobjects c
11 join sysconstraints s on (s.constrid = c.id and s.tableid = object_id('aumen_masivo_det_archivo'))
12 where name = 'FK_detalle_REF_cabecera' and type = 'RI')
13 alter table aumen_masivo_det_archivo
14 drop constraint FK_detalle_REF_cabecera
15go
16
17if exists (select 1
18 from sysobjects c
19 join sysconstraints s on (s.constrid = c.id and s.tableid = object_id('aumen_masivo_errores_det_arch'))
20 where name = 'FK_AUMEN_MA_REFERENCE_AUMEN_MA' and type = 'RI')
21 alter table aumen_masivo_errores_det_arch
22 drop constraint FK_AUMEN_MA_REFERENCE_AUMEN_MA
23go
24
25if exists (select 1
26 from sysobjects
27 where id = object_id('aumen_masivo_det_archivo')
28 and type = 'U')
29 drop table aumen_masivo_det_archivo
30go
31
32/*==============================================================*/
33/* Table: aumen_masivo_det_archivo */
34/*==============================================================*/
35create table aumen_masivo_det_archivo (
36 id_job integer not null,
37 id_archivo_aumento integer not null,
38 item integer not null,
39 tipo_registro char(20) null,
40 nomen tinyint null,
41 codigo char(10) null,
42 concep char(20) null,
43 opcion_concepto char(40) null,
44 moneda char(5) null,
45 porc_mas_valor_propio decimal(5,2) null,
46 porc_menos_valor_propio decimal(5,2) null,
47 por_valor_propio decimal(5,2) null,
48 valor decimal(12,2) null,
49 unidad decimal(12,2) null,
50 opcion_valor_propio char(40) null,
51 porc_urgencia_diurna decimal(5,2) null,
52 porc_urgencia_nocturna decimal(5,2) null,
53 plus decimal(12,2) null,
54 opciones_val_plus char(40) null,
55 incluye_normas char(30) null,
56 excluye_normas char(30) null,
57 dias decimal(12,2) null,
58 dias_sala char(30) null,
59 opciones_normas char(40) null,
60 procesa_baja char(2) null,
61 estado_registro char(2) not null,
62 fecha_estado datetime not null,
63 constraint PK_AUMEN_MASIVO_DET_ARCHIVO primary key (id_job, id_archivo_aumento, item)
64)
65go
66
67alter table aumen_masivo_det_archivo
68 add constraint FK_AUMEN_MA_REF_estados foreign key (estado_registro)
69 references aumen_masivo_estados (id_estado)
70go
71
72alter table aumen_masivo_det_archivo
73 add constraint FK_detalle_REF_cabecera foreign key (id_job, id_archivo_aumento)
74 references aumen_masivo_cab_archivo (id_job, id_archivo_aumento)
75go