· 8 years ago · Dec 24, 2017, 09:30 PM
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_archivo'))
4 where name = 'FK_AUMEN_MA_REFERENCE_AUMEN_MA' and type = 'RI')
5 alter table aumen_masivo_errores_archivo
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_archivo'))
12 where name = 'FK_AUMEN_MA_REFERENCE_ERRORES_' and type = 'RI')
13 alter table aumen_masivo_errores_archivo
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_archivo')
20 and type = 'U')
21 drop table aumen_masivo_errores_archivo
22go
23
24/*==============================================================*/
25/* Table: aumen_masivo_errores_archivo */
26/*==============================================================*/
27create table aumen_masivo_errores_archivo (
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 constraint PK_AUMEN_MASIVO_ERRORES_ARCHIV primary key (id_job, id_archivo_aumento, item, secuencia)
34)
35go
36
37alter table aumen_masivo_errores_archivo
38 add constraint FK_AUMEN_MA_REFERENCE_AUMEN_MA foreign key (id_job, id_archivo_aumento, item)
39 references aumen_masivo_det_archivo (id_job, id_archivo_aumento, item)
40go
41
42alter table aumen_masivo_errores_archivo
43 add constraint FK_AUMEN_MA_REFERENCE_ERRORES_ foreign key (id_error)
44 references errores_aumento_masivo (id_error)
45go