Sie sind auf Seite 1von 4

jamontano@segurosmilenio.

co

PRINT N'Adding foreign keys to [Cambiario].[tmNumeralesCambiarios]'


GO
ALTER TABLE [Cambiario].[tmNumeralesCambiarios] ADD CONSTRAINT
[FK_tmNumeralesCambiarios_tmFormulariosCambiariosNumeros] FOREIGN KEY
([intIdNmroFrmlrioCmbiario]) REFERENCES [Cambiario].
[tmFormulariosCambiariosNumeros] ([intIdNmroFrmlrioCmbiario])
GO
ALTER TABLE [Cambiario].[tmNumeralesCambiarios] ADD CONSTRAINT
[FK_tmNumeralesCambiarios_tmOperacionesCambiarias] FOREIGN KEY
([intIdOprcionCmbiaria]) REFERENCES [Cambiario].[tmOperacionesCambiarias]
([intIdOprcionCmbiaria])
GO
ALTER TABLE [Cambiario].[tmNumeralesCambiarios] ADD CONSTRAINT
[FK_tmNumeralesCambiarios_tmOperacionesCambiarias1] FOREIGN KEY
([intIdOprcionCmbiariaF10]) REFERENCES [Cambiario].[tmOperacionesCambiarias]
([intIdOprcionCmbiaria])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [Cambiario].
[tmvPagosImportacionesAnticiposEncabezado]'
GO
ALTER TABLE [Cambiario].[tmvPagosImportacionesAnticiposEncabezado] ADD CONSTRAINT
[FK_tmvPagosImportacionesAnticiposEncabezado_tmImportadorExportador] FOREIGN KEY
([intIdImprtdorExprtdor]) REFERENCES [dbo].[tmImportadorExportador]
([intIdImprtdorExprtdor])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [RegistroImportacion].[tmvRegistroImportacion]'
GO
ALTER TABLE [RegistroImportacion].[tmvRegistroImportacion] ADD CONSTRAINT
[FK_tmvRegistroImportacion_tmImportadorExportador] FOREIGN KEY
([intIdImprtdorExprtdor]) REFERENCES [dbo].[tmImportadorExportador]
([intIdImprtdorExprtdor])
GO
ALTER TABLE [RegistroImportacion].[tmvRegistroImportacion] ADD CONSTRAINT
[FK_tmvRegistroImportacion_tmProveedores] FOREIGN KEY ([intIdPrvdor]) REFERENCES
[dbo].[tmProveedores] ([intIdPrvdor])
GO
ALTER TABLE [RegistroImportacion].[tmvRegistroImportacion] ADD CONSTRAINT
[FK_tmvRegistroImportacion_tmAduanas1] FOREIGN KEY ([intIdAduana]) REFERENCES
[dbo].[tmAduanas] ([intIdAduana]) ON UPDATE CASCADE
GO
ALTER TABLE [RegistroImportacion].[tmvRegistroImportacion] ADD CONSTRAINT
[FK_tmvRegistroImportacion_tmPaises] FOREIGN KEY ([intIdPais]) REFERENCES [dbo].
[tmPaises] ([intIdpais])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [costos].
[tmEstructuraCostosImportacionCotizaciones]'
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizacion_tmAduanas] FOREIGN KEY ([intIdAduana])
REFERENCES [dbo].[tmAduanas] ([intIdAduana])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizacion_tmEstructuraCostosImportacion] FOREIGN
KEY ([intIdVriableGsto]) REFERENCES [costos].[tmEstructuraCostosImportacion]
([intIdVriableGsto]) ON DELETE CASCADE
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizacion_tmIncoterms] FOREIGN KEY
([intIdIncterms]) REFERENCES [dbo].[tmIncoterms] ([intIdIncterms])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizacion_tmTipoEmbalaje] FOREIGN KEY
([intIdTpoEmblje]) REFERENCES [logistica].[tmTipoEmbalaje] ([intIdTpoEmblje])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizaciones_tmDestinos] FOREIGN KEY
([intIdDstno]) REFERENCES [logistica].[tmDestinos] ([intIdDstno])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizaciones_tmLugaresEmbarque] FOREIGN KEY
([intIdLgarEmbrque]) REFERENCES [logistica].[tmLugaresEmbarque]
([intIdLgarEmbrque])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizaciones_tmMonedas] FOREIGN KEY ([intIdMnda])
REFERENCES [dbo].[tmMonedas] ([intIdMnda])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizaciones_tmOperadoresLogisticosRangos] FOREIGN
KEY ([intIdOprdorLgstcoRngo]) REFERENCES [tarifas].[tmOperadoresLogisticosRangos]
([intIdOprdorLgstcoRngo])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizaciones_tmOrdenesCompraTipo] FOREIGN KEY
([intIdTpoOrden]) REFERENCES [logistica].[tmOrdenesCompraTipo] ([intIdTpoOrden])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizaciones_tmProveedores] FOREIGN KEY
([intIdPrvdor]) REFERENCES [dbo].[tmProveedores] ([intIdPrvdor])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizaciones_tmTerceros] FOREIGN KEY
([intIdTrcro]) REFERENCES [logistica].[tmTerceros] ([intIdTrcro])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizaciones_tmTerceros1] FOREIGN KEY
([intIdEmbrcdor]) REFERENCES [logistica].[tmTerceros] ([intIdTrcro])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizaciones_tmTransportes] FOREIGN KEY
([intIdTrnsprte]) REFERENCES [logistica].[tmTransportes] ([intIdTrnsprte])
GO
ALTER TABLE [costos].[tmEstructuraCostosImportacionCotizaciones] ADD CONSTRAINT
[FK_tmEstructuraCostosImportacionCotizaciones_tmUnidades] FOREIGN KEY
([intIdUndadTrfa]) REFERENCES [dbo].[tmUnidades] ([intIdUndad])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [logistica].[tmTerceros]'
GO
ALTER TABLE [logistica].[tmTerceros] ADD CONSTRAINT [FK_tmTerceros_tmBancos]
FOREIGN KEY ([intIdBnco]) REFERENCES [dbo].[tmBancos] ([intIdBnco])
GO
ALTER TABLE [logistica].[tmTerceros] ADD CONSTRAINT [FK_tmTerceros_tmCiudades]
FOREIGN KEY ([intIdCiudad]) REFERENCES [dbo].[tmCiudades] ([intIdCiudad])
GO
ALTER TABLE [logistica].[tmTerceros] ADD CONSTRAINT [FK_tmTerceros_tmPaises]
FOREIGN KEY ([intIdPais]) REFERENCES [dbo].[tmPaises] ([intIdpais])
GO
ALTER TABLE [logistica].[tmTerceros] ADD CONSTRAINT [FK_tmTerceros_tmRetefuente]
FOREIGN KEY ([intIdRtncionfuente]) REFERENCES [dbo].[tmRetefuente]
([intIdRtncionfuente])
GO
ALTER TABLE [logistica].[tmTerceros] ADD CONSTRAINT [FK_tmTerceros_tmRetencionIva]
FOREIGN KEY ([intIdRtncionIva]) REFERENCES [cromo].[tmRetencionIva]
([intIdRtncionIva])
GO
ALTER TABLE [logistica].[tmTerceros] ADD CONSTRAINT [FK_tmTerceros_tmSector]
FOREIGN KEY ([intIdSctor]) REFERENCES [cromo].[tmSector] ([intIdSctor])
GO
ALTER TABLE [logistica].[tmTerceros] ADD CONSTRAINT
[FK_tmTerceros_tmTercerosOtrasClasificaciones] FOREIGN KEY
([intIdOtraClsfccionTrcro]) REFERENCES [logistica].[tmTercerosOtrasClasificaciones]
([intIdOtraClsfccionTrcro])
GO
ALTER TABLE [logistica].[tmTerceros] ADD CONSTRAINT [FK_tmTerceros_tmTercerosTipos]
FOREIGN KEY ([intIdTpoTrcro]) REFERENCES [logistica].[tmTercerosTipos]
([intIdTpoTrcro])
GO
ALTER TABLE [logistica].[tmTerceros] ADD CONSTRAINT [FK_tmTerceros_tmTipoCliente]
FOREIGN KEY ([intIdTpoClnte]) REFERENCES [cromo].[tmTipoCliente] ([intIdTpoClnte])
GO
ALTER TABLE [logistica].[tmTerceros] ADD CONSTRAINT
[FK_tmTerceros_tmTiposDocumentosIdentificacion] FOREIGN KEY
([intIdTpoDcmntoIdntfccion]) REFERENCES [DUA].[tmTiposDocumentosIdentificacion]
([intIdTpoDcmntoIdntfccion])
GO
ALTER TABLE [logistica].[tmTerceros] ADD CONSTRAINT [FK_tmTerceros_tmTransportes]
FOREIGN KEY ([intIdTrnsprte]) REFERENCES [logistica].[tmTransportes]
([intIdTrnsprte])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [logistica].[tmvOrdenesCompraEncabezado]'
GO
ALTER TABLE [logistica].[tmvOrdenesCompraEncabezado] ADD CONSTRAINT
[FK_tmvOrdenesCompraEncabezado_tmProveedores] FOREIGN KEY ([intIdPrvdor])
REFERENCES [dbo].[tmProveedores] ([intIdPrvdor])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [logistica].
[tmvPosiblesEntregasPlaneacionImportacion]'
GO
ALTER TABLE [logistica].[tmvPosiblesEntregasPlaneacionImportacion] ADD CONSTRAINT
[FK_tmvPosiblesEntregasPlaneacionImportacion_tmFormasPago] FOREIGN KEY
([intIdFrmaPgo]) REFERENCES [dbo].[tmFormasPago] ([intIdFrmaPgo])
GO
ALTER TABLE [logistica].[tmvPosiblesEntregasPlaneacionImportacion] ADD CONSTRAINT
[FK_tmvPosiblesEntregasPlaneacionImportacion_tmTemporada] FOREIGN KEY
([intidTmprda]) REFERENCES [dbo].[tmClasificaciones] ([intIdClsfccion])
GO
ALTER TABLE [logistica].[tmvPosiblesEntregasPlaneacionImportacion] ADD CONSTRAINT
[FK_tmvPosiblesEntregasPlaneacionImportacion_tmvPosiblesEntregasEncabezado] FOREIGN
KEY ([intIdPsbleEntrga]) REFERENCES [logistica].[tmvPosiblesEntregasEncabezado]
([intIdPsbleEntrga])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [planVallejo].[tmCuadroInsumoProductoInsumos]'
GO
ALTER TABLE [planVallejo].[tmCuadroInsumoProductoInsumos] ADD CONSTRAINT
[FK_tmCuadroInsumoProductoInsumos_tmAlmacenes] FOREIGN KEY ([intIdAlmcen])
REFERENCES [dbo].[tmAlmacenes] ([intIdAlmcen])
GO
ALTER TABLE [planVallejo].[tmCuadroInsumoProductoInsumos] ADD CONSTRAINT
[FK_tmCuadroInsumoProductoInsumos_tmCuadrosInsumoProducto] FOREIGN KEY
([intIdCuadroInsmoPrdcto]) REFERENCES [planVallejo].[tmCuadrosInsumoProducto]
([intIdCuadroInsmoPrdcto]) ON DELETE CASCADE
GO
ALTER TABLE [planVallejo].[tmCuadroInsumoProductoInsumos] ADD CONSTRAINT
[FK_tmCuadroInsumoProductoInsumos_tmInsumos] FOREIGN KEY ([intIdInsmo]) REFERENCES
[dbo].[tmInsumos] ([intIdInsmo])
GO
ALTER TABLE [planVallejo].[tmCuadroInsumoProductoInsumos] ADD CONSTRAINT
[FK_tmCuadroInsumoProductoInsumos_tmResiduosTipo] FOREIGN KEY ([intIdTpoRsduo])
REFERENCES [planVallejo].[tmResiduosTipo] ([intIdTpoRsduo])

ALTER TABLE [Cambiario].[tmNumeralesCambiariosTipos] ADD


[intIdNumeralesCambiariosTipo] [int] NOT NULL IDENTITY(1, 1)
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_tmNumeralesCambiariosTipos] on [Cambiario].
[tmNumeralesCambiariosTipos]'
GO
ALTER TABLE [Cambiario].[tmNumeralesCambiariosTipos] ADD CONSTRAINT
[PK_tmNumeralesCambiariosTipos] PRIMARY KEY CLUSTERED
([intIdNumeralesCambiariosTipo])
GO
PRINT N'Adding foreign keys to [CI].[tmCPDetalle]'
GO
ALTER TABLE [CI].[tmCPDetalle] ADD CONSTRAINT [FK_tmCPDetalle_tmCPEncabezado]
FOREIGN KEY ([intIdCp]) REFERENCES [CI].[tmCPEncabezado] ([intIdCP])

Das könnte Ihnen auch gefallen