Description
Properties
| Name | Value |
|---|---|
| File Collation | |
| File Group | |
| Filestream File Group | |
| Is Partitioned | False |
| Partitioned Column | |
| Partition Scheme | |
| File Groups | |
| Filestream Partition Scheme | |
| Filestream File Groups | |
| Heap | True |
| Full Text Catalog | |
| Full Text | |
| Compression | NONE |
| Row Count (~) | 0 |
| Created | 10/1/2007 3:29:33 PM |
| Last Modified | 11/30/2024 5:55:14 PM |
Columns
6| Key | Name | Data Type | Length | Precision | Scale | Not Null | Identity | Rule | Default | Computed | Persisted | Description |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| contrato | smallint | 2 | 5 | 0 | True |
False |
False |
|||||
| nombre_contrato | varchar | 100 | 0 | 0 | False |
False |
False |
|||||
| fecha_vigencia | smalldatetime | 4 | 16 | 0 | False |
False |
False |
|||||
| fecha_vencimiento | smalldatetime | 4 | 16 | 0 | False |
False |
False |
|||||
| cliente | int | 4 | 10 | 0 | False |
False |
False |
|||||
| detalle_contrato | text | 0 | 0 | False |
False |
False |
Triggers
3| Name | ANSI Nulls ON | Quoted Identifier ON | On | Not For Replication | Description |
|---|---|---|---|---|---|
| tD_contratos | True |
True |
AFTER DELETE | False |
|
| tI_contratos | True |
True |
AFTER INSERT | False |
|
| tU_contratos | True |
True |
AFTER UPDATE | False |
Foreign Keys
1| Name | Columns | Description |
|---|---|---|
| FK__contratos__clien__5812160E | cliente |
SQL Script
Copy
CREATE TABLE dbo.contratos (
contrato smallint NOT NULL,
nombre_contrato varchar(100) NULL,
fecha_vigencia smalldatetime NULL,
fecha_vencimiento smalldatetime NULL,
cliente int NULL,
detalle_contrato text NULL,
PRIMARY KEY NONCLUSTERED (contrato) WITH (FILLFACTOR = 90)
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER trigger dbo.tD_contratos on dbo.contratos for DELETE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* DELETE trigger on contratos */
begin
declare @errno int,
@errmsg varchar(255)
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* contratos R/256 informes ON PARENT DELETE SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="contratos"
CHILD_OWNER="", CHILD_TABLE="informes"
P2C_VERB_PHRASE="R/256", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_256", FK_COLUMNS="contrato" */
update informes
set
/* %SetFK(informes,NULL) */
informes.contrato = NULL
from informes,deleted
where
/* %JoinFKPK(informes,deleted," = "," and") */
informes.contrato = deleted.contrato
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* contratos R/255 contratos_informes ON PARENT DELETE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="contratos"
CHILD_OWNER="", CHILD_TABLE="contratos_informes"
P2C_VERB_PHRASE="R/255", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_255", FK_COLUMNS="contrato" */
if exists (
select * from deleted,contratos_informes
where
/* %JoinFKPK(contratos_informes,deleted," = "," and") */
contratos_informes.contrato = deleted.contrato
)
begin
select @errno = 30001,
@errmsg = 'Cannot DELETE contratos because contratos_informes exists.'
goto error
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
return
error:
raiserror (@errmsg,@errno,1)
rollback transaction
end
GO
CREATE OR ALTER trigger dbo.tI_contratos on dbo.contratos for INSERT as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* INSERT trigger on contratos */
begin
declare @numrows int,
@nullcnt int,
@validcnt int,
@errno int,
@errmsg varchar(255)
select @numrows = @@rowcount
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* clientes R/254 contratos ON CHILD INSERT SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="clientes"
CHILD_OWNER="", CHILD_TABLE="contratos"
P2C_VERB_PHRASE="R/254", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_254", FK_COLUMNS="cliente" */
if
/* %ChildFK(" or",update) */
update(cliente)
begin
update contratos
set
/* %SetFK(contratos,NULL) */
contratos.cliente = NULL
from contratos,inserted
where
/* %JoinPKPK(contratos,inserted," = "," and") */
contratos.contrato = inserted.contrato and
not exists (
select * from clientes
where
/* %JoinFKPK(inserted,clientes," = "," and") */
inserted.cliente = clientes.cliente
)
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
return
error:
raiserror (@errmsg,@errno,1)
rollback transaction
end
GO
CREATE OR ALTER trigger dbo.tU_contratos on dbo.contratos for UPDATE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* UPDATE trigger on contratos */
begin
declare @numrows int,
@nullcnt int,
@validcnt int,
@inscontrato smallint,
@errno int,
@errmsg varchar(255)
select @numrows = @@rowcount
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* contratos R/256 informes ON PARENT UPDATE SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="contratos"
CHILD_OWNER="", CHILD_TABLE="informes"
P2C_VERB_PHRASE="R/256", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_256", FK_COLUMNS="contrato" */
if
/* %ParentPK(" or",update) */
update(contrato)
begin
update informes
set
/* %SetFK(informes,NULL) */
informes.contrato = NULL
from informes,deleted
where
/* %JoinFKPK(informes,deleted," = "," and") */
informes.contrato = deleted.contrato
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* contratos R/255 contratos_informes ON PARENT UPDATE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="contratos"
CHILD_OWNER="", CHILD_TABLE="contratos_informes"
P2C_VERB_PHRASE="R/255", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_255", FK_COLUMNS="contrato" */
if
/* %ParentPK(" or",update) */
update(contrato)
begin
if exists (
select * from deleted,contratos_informes
where
/* %JoinFKPK(contratos_informes,deleted," = "," and") */
contratos_informes.contrato = deleted.contrato
)
begin
select @errno = 30005,
@errmsg = 'Cannot UPDATE contratos because contratos_informes exists.'
goto error
end
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* clientes R/254 contratos ON CHILD UPDATE SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="clientes"
CHILD_OWNER="", CHILD_TABLE="contratos"
P2C_VERB_PHRASE="R/254", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_254", FK_COLUMNS="cliente" */
if
/* %ChildFK(" or",update) */
update(cliente)
begin
update contratos
set
/* %SetFK(contratos,NULL) */
contratos.cliente = NULL
from contratos,inserted
where
/* %JoinPKPK(contratos,inserted," = "," and") */
contratos.contrato = inserted.contrato and
not exists (
select * from clientes
where
/* %JoinFKPK(inserted,clientes," = "," and") */
inserted.cliente = clientes.cliente
)
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
return
error:
raiserror (@errmsg,@errno,1)
rollback transaction
end
GO
ALTER TABLE dbo.contratos WITH NOCHECK
ADD CONSTRAINT FK__contratos__clien__5812160E FOREIGN KEY (cliente) REFERENCES dbo.clientes (cliente)
GO
contrato smallint NOT NULL,
nombre_contrato varchar(100) NULL,
fecha_vigencia smalldatetime NULL,
fecha_vencimiento smalldatetime NULL,
cliente int NULL,
detalle_contrato text NULL,
PRIMARY KEY NONCLUSTERED (contrato) WITH (FILLFACTOR = 90)
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER trigger dbo.tD_contratos on dbo.contratos for DELETE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* DELETE trigger on contratos */
begin
declare @errno int,
@errmsg varchar(255)
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* contratos R/256 informes ON PARENT DELETE SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="contratos"
CHILD_OWNER="", CHILD_TABLE="informes"
P2C_VERB_PHRASE="R/256", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_256", FK_COLUMNS="contrato" */
update informes
set
/* %SetFK(informes,NULL) */
informes.contrato = NULL
from informes,deleted
where
/* %JoinFKPK(informes,deleted," = "," and") */
informes.contrato = deleted.contrato
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* contratos R/255 contratos_informes ON PARENT DELETE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="contratos"
CHILD_OWNER="", CHILD_TABLE="contratos_informes"
P2C_VERB_PHRASE="R/255", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_255", FK_COLUMNS="contrato" */
if exists (
select * from deleted,contratos_informes
where
/* %JoinFKPK(contratos_informes,deleted," = "," and") */
contratos_informes.contrato = deleted.contrato
)
begin
select @errno = 30001,
@errmsg = 'Cannot DELETE contratos because contratos_informes exists.'
goto error
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
return
error:
raiserror (@errmsg,@errno,1)
rollback transaction
end
GO
CREATE OR ALTER trigger dbo.tI_contratos on dbo.contratos for INSERT as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* INSERT trigger on contratos */
begin
declare @numrows int,
@nullcnt int,
@validcnt int,
@errno int,
@errmsg varchar(255)
select @numrows = @@rowcount
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* clientes R/254 contratos ON CHILD INSERT SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="clientes"
CHILD_OWNER="", CHILD_TABLE="contratos"
P2C_VERB_PHRASE="R/254", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_254", FK_COLUMNS="cliente" */
if
/* %ChildFK(" or",update) */
update(cliente)
begin
update contratos
set
/* %SetFK(contratos,NULL) */
contratos.cliente = NULL
from contratos,inserted
where
/* %JoinPKPK(contratos,inserted," = "," and") */
contratos.contrato = inserted.contrato and
not exists (
select * from clientes
where
/* %JoinFKPK(inserted,clientes," = "," and") */
inserted.cliente = clientes.cliente
)
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
return
error:
raiserror (@errmsg,@errno,1)
rollback transaction
end
GO
CREATE OR ALTER trigger dbo.tU_contratos on dbo.contratos for UPDATE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* UPDATE trigger on contratos */
begin
declare @numrows int,
@nullcnt int,
@validcnt int,
@inscontrato smallint,
@errno int,
@errmsg varchar(255)
select @numrows = @@rowcount
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* contratos R/256 informes ON PARENT UPDATE SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="contratos"
CHILD_OWNER="", CHILD_TABLE="informes"
P2C_VERB_PHRASE="R/256", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_256", FK_COLUMNS="contrato" */
if
/* %ParentPK(" or",update) */
update(contrato)
begin
update informes
set
/* %SetFK(informes,NULL) */
informes.contrato = NULL
from informes,deleted
where
/* %JoinFKPK(informes,deleted," = "," and") */
informes.contrato = deleted.contrato
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* contratos R/255 contratos_informes ON PARENT UPDATE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="contratos"
CHILD_OWNER="", CHILD_TABLE="contratos_informes"
P2C_VERB_PHRASE="R/255", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_255", FK_COLUMNS="contrato" */
if
/* %ParentPK(" or",update) */
update(contrato)
begin
if exists (
select * from deleted,contratos_informes
where
/* %JoinFKPK(contratos_informes,deleted," = "," and") */
contratos_informes.contrato = deleted.contrato
)
begin
select @errno = 30005,
@errmsg = 'Cannot UPDATE contratos because contratos_informes exists.'
goto error
end
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* clientes R/254 contratos ON CHILD UPDATE SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="clientes"
CHILD_OWNER="", CHILD_TABLE="contratos"
P2C_VERB_PHRASE="R/254", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_254", FK_COLUMNS="cliente" */
if
/* %ChildFK(" or",update) */
update(cliente)
begin
update contratos
set
/* %SetFK(contratos,NULL) */
contratos.cliente = NULL
from contratos,inserted
where
/* %JoinPKPK(contratos,inserted," = "," and") */
contratos.contrato = inserted.contrato and
not exists (
select * from clientes
where
/* %JoinFKPK(inserted,clientes," = "," and") */
inserted.cliente = clientes.cliente
)
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
return
error:
raiserror (@errmsg,@errno,1)
rollback transaction
end
GO
ALTER TABLE dbo.contratos WITH NOCHECK
ADD CONSTRAINT FK__contratos__clien__5812160E FOREIGN KEY (cliente) REFERENCES dbo.clientes (cliente)
GO
Depends On
4- Fidelitas
- dbo.clientes
- dbo.contratos_informes
- dbo.informes