· 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_errores_det_arch'))
4 where name = 'FK_AUMEN_MA_REFERENCE_AUMEN_MA' and type = 'RI')
5 alter table aumen_masivo_errores_det_arch
6 drop constraint FK_AUMEN_MA_REFERENCE_AUMEN_MA
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_errores_det_arch'))
12 where name = 'FK_AUMEN_MA_REFERENCE_ERRORES_' and type = 'RI')
13 alter table aumen_masivo_errores_det_arch
14 drop constraint FK_AUMEN_MA_REFERENCE_ERRORES_
15go
16
17if exists (select 1
18 from sysobjects
19 where id = object_id('aumen_masivo_errores_det_arch')
20 and type = 'U')
21 drop table aumen_masivo_errores_det_arch
22go
23
24/*==============================================================*/
25/* Table: aumen_masivo_errores_det_arch */
26/*==============================================================*/
27create table aumen_masivo_errores_det_arch (
28 id_job integer not null,
29 id_archivo_aumento integer not null,
30 item integer not null,
31 secuencia smallint not null,
32 id_error smallint not null,
33 detalle_error varchar(100) null,
34 constraint PK_AUMEN_MASIVO_ERRORES_DET_AR primary key (id_job, id_archivo_aumento, item, secuencia)
35)
36go
37
38alter table aumen_masivo_errores_det_arch
39 add constraint FK_AUMEN_MA_REFERENCE_AUMEN_MA foreign key (id_job, id_archivo_aumento, item)
40 references aumen_masivo_det_archivo (id_job, id_archivo_aumento, item)
41go
42
43alter table aumen_masivo_errores_det_arch
44 add constraint FK_AUMEN_MA_REFERENCE_ERRORES_ foreign key (id_error)
45 references errores_aumento_masivo (id_error)
46go