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 (~) | 25 |
| Created | 10/1/2007 3:29:34 PM |
| Last Modified | 11/23/2022 4:42:20 PM |
Columns
6| Key | Name | Data Type | Length | Precision | Scale | Not Null | Identity | Rule | Default | Computed | Persisted | Description |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| rol | smallint | 2 | 5 | 0 | True |
False |
False |
|||||
| nombre_rol | varchar | 30 | 0 | 0 | False |
False |
False |
|||||
| datamanager | tinyint | 1 | 3 | 0 | False |
False |
False |
|||||
| country_code | varchar | 2 | 0 | 0 | False |
False |
False |
|||||
| activo | bit | 1 | 1 | 0 | True |
(1) | False |
False |
||||
| plataforma | varchar | 10 | 0 | 0 | True |
('BLUE') | False |
False |
Triggers
3| Name | ANSI Nulls ON | Quoted Identifier ON | On | Not For Replication | Description |
|---|---|---|---|---|---|
| tD_roles | True |
True |
AFTER DELETE | False |
|
| tI_roles | True |
True |
AFTER INSERT | False |
|
| tU_roles | True |
True |
AFTER UPDATE | False |
Foreign Keys
1| Name | Columns | Description |
|---|---|---|
| FK__roles__country_c__6D0D32F4 | country_code |
SQL Script
Copy
CREATE TABLE dbo.roles (
rol smallint NOT NULL,
nombre_rol varchar(30) NULL,
datamanager tinyint NULL,
country_code varchar(2) NULL,
activo bit NOT NULL DEFAULT (1),
plataforma varchar(10) NOT NULL DEFAULT ('BLUE'),
PRIMARY KEY NONCLUSTERED (rol) WITH (FILLFACTOR = 90)
)
ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER trigger dbo.tD_roles on dbo.roles for DELETE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* DELETE trigger on roles */
begin
declare @errno int,
@errmsg varchar(255)
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* roles R/257 roles_tipo_informe ON PARENT DELETE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="roles"
CHILD_OWNER="", CHILD_TABLE="roles_tipo_informe"
P2C_VERB_PHRASE="R/257", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_257", FK_COLUMNS="rol" */
if exists (
select * from deleted,roles_tipo_informe
where
/* %JoinFKPK(roles_tipo_informe,deleted," = "," and") */
roles_tipo_informe.rol = deleted.rol
)
begin
select @errno = 30001,
@errmsg = 'Cannot DELETE roles because roles_tipo_informe exists.'
goto error
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* roles R/240 usuarios_roles ON PARENT DELETE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="roles"
CHILD_OWNER="", CHILD_TABLE="usuarios_roles"
P2C_VERB_PHRASE="R/240", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_240", FK_COLUMNS="rol" */
if exists (
select * from deleted,usuarios_roles
where
/* %JoinFKPK(usuarios_roles,deleted," = "," and") */
usuarios_roles.rol = deleted.rol
)
begin
select @errno = 30001,
@errmsg = 'Cannot DELETE roles because usuarios_roles 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_roles on dbo.roles for INSERT as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* INSERT trigger on roles */
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 */
/* country R/238 roles ON CHILD INSERT SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
CHILD_OWNER="", CHILD_TABLE="roles"
P2C_VERB_PHRASE="R/238", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_238", FK_COLUMNS="country_code" */
if
/* %ChildFK(" or",update) */
update(country_code)
begin
update roles
set
/* %SetFK(roles,NULL) */
roles.country_code = NULL
from roles,inserted
where
/* %JoinPKPK(roles,inserted," = "," and") */
roles.rol = inserted.rol and
not exists (
select * from country
where
/* %JoinFKPK(inserted,country," = "," and") */
inserted.country_code = country.country_code
)
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_roles on dbo.roles for UPDATE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* UPDATE trigger on roles */
begin
declare @numrows int,
@nullcnt int,
@validcnt int,
@insrol smallint,
@errno int,
@errmsg varchar(255)
select @numrows = @@rowcount
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* roles R/257 roles_tipo_informe ON PARENT UPDATE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="roles"
CHILD_OWNER="", CHILD_TABLE="roles_tipo_informe"
P2C_VERB_PHRASE="R/257", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_257", FK_COLUMNS="rol" */
if
/* %ParentPK(" or",update) */
update(rol)
begin
if exists (
select * from deleted,roles_tipo_informe
where
/* %JoinFKPK(roles_tipo_informe,deleted," = "," and") */
roles_tipo_informe.rol = deleted.rol
)
begin
select @errno = 30005,
@errmsg = 'Cannot UPDATE roles because roles_tipo_informe exists.'
goto error
end
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* roles R/240 usuarios_roles ON PARENT UPDATE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="roles"
CHILD_OWNER="", CHILD_TABLE="usuarios_roles"
P2C_VERB_PHRASE="R/240", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_240", FK_COLUMNS="rol" */
if
/* %ParentPK(" or",update) */
update(rol)
begin
if exists (
select * from deleted,usuarios_roles
where
/* %JoinFKPK(usuarios_roles,deleted," = "," and") */
usuarios_roles.rol = deleted.rol
)
begin
select @errno = 30005,
@errmsg = 'Cannot UPDATE roles because usuarios_roles exists.'
goto error
end
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* country R/238 roles ON CHILD UPDATE SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
CHILD_OWNER="", CHILD_TABLE="roles"
P2C_VERB_PHRASE="R/238", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_238", FK_COLUMNS="country_code" */
if
/* %ChildFK(" or",update) */
update(country_code)
begin
update roles
set
/* %SetFK(roles,NULL) */
roles.country_code = NULL
from roles,inserted
where
/* %JoinPKPK(roles,inserted," = "," and") */
roles.rol = inserted.rol and
not exists (
select * from country
where
/* %JoinFKPK(inserted,country," = "," and") */
inserted.country_code = country.country_code
)
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
return
error:
raiserror (@errmsg,@errno,1)
rollback transaction
end
GO
ALTER TABLE dbo.roles
ADD FOREIGN KEY (country_code) REFERENCES dbo.country (country_code)
GO
rol smallint NOT NULL,
nombre_rol varchar(30) NULL,
datamanager tinyint NULL,
country_code varchar(2) NULL,
activo bit NOT NULL DEFAULT (1),
plataforma varchar(10) NOT NULL DEFAULT ('BLUE'),
PRIMARY KEY NONCLUSTERED (rol) WITH (FILLFACTOR = 90)
)
ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER trigger dbo.tD_roles on dbo.roles for DELETE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* DELETE trigger on roles */
begin
declare @errno int,
@errmsg varchar(255)
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* roles R/257 roles_tipo_informe ON PARENT DELETE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="roles"
CHILD_OWNER="", CHILD_TABLE="roles_tipo_informe"
P2C_VERB_PHRASE="R/257", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_257", FK_COLUMNS="rol" */
if exists (
select * from deleted,roles_tipo_informe
where
/* %JoinFKPK(roles_tipo_informe,deleted," = "," and") */
roles_tipo_informe.rol = deleted.rol
)
begin
select @errno = 30001,
@errmsg = 'Cannot DELETE roles because roles_tipo_informe exists.'
goto error
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* roles R/240 usuarios_roles ON PARENT DELETE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="roles"
CHILD_OWNER="", CHILD_TABLE="usuarios_roles"
P2C_VERB_PHRASE="R/240", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_240", FK_COLUMNS="rol" */
if exists (
select * from deleted,usuarios_roles
where
/* %JoinFKPK(usuarios_roles,deleted," = "," and") */
usuarios_roles.rol = deleted.rol
)
begin
select @errno = 30001,
@errmsg = 'Cannot DELETE roles because usuarios_roles 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_roles on dbo.roles for INSERT as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* INSERT trigger on roles */
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 */
/* country R/238 roles ON CHILD INSERT SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
CHILD_OWNER="", CHILD_TABLE="roles"
P2C_VERB_PHRASE="R/238", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_238", FK_COLUMNS="country_code" */
if
/* %ChildFK(" or",update) */
update(country_code)
begin
update roles
set
/* %SetFK(roles,NULL) */
roles.country_code = NULL
from roles,inserted
where
/* %JoinPKPK(roles,inserted," = "," and") */
roles.rol = inserted.rol and
not exists (
select * from country
where
/* %JoinFKPK(inserted,country," = "," and") */
inserted.country_code = country.country_code
)
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_roles on dbo.roles for UPDATE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* UPDATE trigger on roles */
begin
declare @numrows int,
@nullcnt int,
@validcnt int,
@insrol smallint,
@errno int,
@errmsg varchar(255)
select @numrows = @@rowcount
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* roles R/257 roles_tipo_informe ON PARENT UPDATE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="roles"
CHILD_OWNER="", CHILD_TABLE="roles_tipo_informe"
P2C_VERB_PHRASE="R/257", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_257", FK_COLUMNS="rol" */
if
/* %ParentPK(" or",update) */
update(rol)
begin
if exists (
select * from deleted,roles_tipo_informe
where
/* %JoinFKPK(roles_tipo_informe,deleted," = "," and") */
roles_tipo_informe.rol = deleted.rol
)
begin
select @errno = 30005,
@errmsg = 'Cannot UPDATE roles because roles_tipo_informe exists.'
goto error
end
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* roles R/240 usuarios_roles ON PARENT UPDATE RESTRICT */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="roles"
CHILD_OWNER="", CHILD_TABLE="usuarios_roles"
P2C_VERB_PHRASE="R/240", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_240", FK_COLUMNS="rol" */
if
/* %ParentPK(" or",update) */
update(rol)
begin
if exists (
select * from deleted,usuarios_roles
where
/* %JoinFKPK(usuarios_roles,deleted," = "," and") */
usuarios_roles.rol = deleted.rol
)
begin
select @errno = 30005,
@errmsg = 'Cannot UPDATE roles because usuarios_roles exists.'
goto error
end
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* country R/238 roles ON CHILD UPDATE SET NULL */
/* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
CHILD_OWNER="", CHILD_TABLE="roles"
P2C_VERB_PHRASE="R/238", C2P_VERB_PHRASE="",
FK_CONSTRAINT="R_238", FK_COLUMNS="country_code" */
if
/* %ChildFK(" or",update) */
update(country_code)
begin
update roles
set
/* %SetFK(roles,NULL) */
roles.country_code = NULL
from roles,inserted
where
/* %JoinPKPK(roles,inserted," = "," and") */
roles.rol = inserted.rol and
not exists (
select * from country
where
/* %JoinFKPK(inserted,country," = "," and") */
inserted.country_code = country.country_code
)
end
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
return
error:
raiserror (@errmsg,@errno,1)
rollback transaction
end
GO
ALTER TABLE dbo.roles
ADD FOREIGN KEY (country_code) REFERENCES dbo.country (country_code)
GO