dbo.country

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 (~) 215
Created 10/1/2007 3:29:33 PM
Last Modified 11/29/2024 5:15:57 PM

Columns

7
Key Name Data Type Length Precision Scale Not Null Identity Rule Default Computed Persisted Description
country_code varchar 2 0 0

True

False

False

country_name varchar 50 0 0

False

False

False

codigo_idioma varchar 3 0 0

False

False

False

codigo_ifx smallint 2 5 0

False

False

False

se_usa bit 1 1 0

True

(1)

False

False

nacionalidad varchar 150 0 0

False

False

False

iso3 varchar 3 0 0

False

False

False

Indexes

2
Key Name Columns Unique Type Description
PK__country__09DE7BCC country_code

True

XAK1country country_name

True

Triggers

2
Name ANSI Nulls ON Quoted Identifier ON On Not For Replication Description
tD_country

True

True

AFTER DELETE

False

tU_country

True

True

AFTER UPDATE

False

SQL Script

Copy
CREATE TABLE dbo.country (
  country_code varchar(2) NOT NULL,
  country_name varchar(50) NULL,
  codigo_idioma varchar(3) NULL,
  codigo_ifx smallint NULL,
  se_usa bit NOT NULL CONSTRAINT DF_country_se_usa DEFAULT (1),
  nacionalidad varchar(150) NULL,
  iso3 varchar(3) NULL,
  PRIMARY KEY NONCLUSTERED (country_code) WITH (FILLFACTOR = 90)
)
ON [PRIMARY]
GO

CREATE UNIQUE INDEX XAK1country
  ON dbo.country (country_name)
  WITH (FILLFACTOR = 90)
  ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER trigger dbo.tD_country on dbo.country for DELETE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* DELETE trigger on country */
begin
  declare  @errno   int,
           @errmsg  varchar(255)
    /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
    /* country R/246 identificadores ON PARENT DELETE SET NULL */
    /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
        CHILD_OWNER="", CHILD_TABLE="identificadores"
        P2C_VERB_PHRASE="R/246", C2P_VERB_PHRASE="", 
        FK_CONSTRAINT="R_246", FK_COLUMNS="country_code" */

    update identificadores
      set
        /* %SetFK(identificadores,NULL) */
        identificadores.country_code = NULL
      from identificadores,deleted
      where
        /* %JoinFKPK(identificadores,deleted," = "," and") */
        identificadores.country_code = deleted.country_code

    /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
    /* country R/243 filiales ON PARENT DELETE SET NULL */
    /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
        CHILD_OWNER="", CHILD_TABLE="filiales"
        P2C_VERB_PHRASE="R/243", C2P_VERB_PHRASE="", 
        FK_CONSTRAINT="R_243", FK_COLUMNS="country_code" */

    update filiales
      set
        /* %SetFK(filiales,NULL) */
        filiales.country_code = NULL
      from filiales,deleted
      where
        /* %JoinFKPK(filiales,deleted," = "," and") */
        filiales.country_code = deleted.country_code

    /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
    /* country R/238 roles ON PARENT DELETE 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" */

    update roles
      set
        /* %SetFK(roles,NULL) */
        roles.country_code = NULL
      from roles,deleted
      where
        /* %JoinFKPK(roles,deleted," = "," and") */
        roles.country_code = deleted.country_code

    /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
    /* country R/228 clientes ON PARENT DELETE SET NULL */
    /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
        CHILD_OWNER="", CHILD_TABLE="clientes"
        P2C_VERB_PHRASE="R/228", C2P_VERB_PHRASE="", 
        FK_CONSTRAINT="R_228", FK_COLUMNS="country_code" */

    update clientes
      set
        /* %SetFK(clientes,NULL) */
        clientes.country_code = NULL
      from clientes,deleted
      where
        /* %JoinFKPK(clientes,deleted," = "," and") */
        clientes.country_code = deleted.country_code

    /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
    /* country R/16 client_machines ON PARENT DELETE SET NULL */
    /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
        CHILD_OWNER="", CHILD_TABLE="client_machines"
        P2C_VERB_PHRASE="R/16", C2P_VERB_PHRASE="", 
        FK_CONSTRAINT="R_16", FK_COLUMNS="country_code" */

    update client_machines
      set
        /* %SetFK(client_machines,NULL) */
        client_machines.country_code = NULL
      from client_machines,deleted
      where
        /* %JoinFKPK(client_machines,deleted," = "," and") */
        client_machines.country_code = deleted.country_code

    /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
    /* country R/11 users ON PARENT DELETE SET NULL */
    /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
        CHILD_OWNER="", CHILD_TABLE="users"
        P2C_VERB_PHRASE="R/11", C2P_VERB_PHRASE="", 
        FK_CONSTRAINT="R_11", FK_COLUMNS="country_code" */

    update users
      set
        /* %SetFK(users,NULL) */
        users.country_code = NULL
      from users,deleted
      where
        /* %JoinFKPK(users,deleted," = "," and") */
        users.country_code = deleted.country_code


    /* 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_country on dbo.country for UPDATE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* UPDATE trigger on country */
begin
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @inscountry_code varchar(2),
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount
  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* country R/246 identificadores ON PARENT UPDATE SET NULL */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
      CHILD_OWNER="", CHILD_TABLE="identificadores"
      P2C_VERB_PHRASE="R/246", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_246", FK_COLUMNS="country_code" */

  if
    /* %ParentPK(" or",update) */
    update(country_code)
  begin
    update identificadores
      set
        /* %SetFK(identificadores,NULL) */
        identificadores.country_code = NULL
      from identificadores,deleted
      where
        /* %JoinFKPK(identificadores,deleted," = "," and") */
        identificadores.country_code = deleted.country_code
  end

  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* country R/243 filiales ON PARENT UPDATE SET NULL */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
      CHILD_OWNER="", CHILD_TABLE="filiales"
      P2C_VERB_PHRASE="R/243", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_243", FK_COLUMNS="country_code" */

  if
    /* %ParentPK(" or",update) */
    update(country_code)
  begin
    update filiales
      set
        /* %SetFK(filiales,NULL) */
        filiales.country_code = NULL
      from filiales,deleted
      where
        /* %JoinFKPK(filiales,deleted," = "," and") */
        filiales.country_code = deleted.country_code
  end

  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* country R/238 roles ON PARENT 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
    /* %ParentPK(" or",update) */
    update(country_code)
  begin
    update roles
      set
        /* %SetFK(roles,NULL) */
        roles.country_code = NULL
      from roles,deleted
      where
        /* %JoinFKPK(roles,deleted," = "," and") */
        roles.country_code = deleted.country_code
  end

  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* country R/228 clientes ON PARENT UPDATE SET NULL */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
      CHILD_OWNER="", CHILD_TABLE="clientes"
      P2C_VERB_PHRASE="R/228", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_228", FK_COLUMNS="country_code" */

  if
    /* %ParentPK(" or",update) */
    update(country_code)
  begin
    update clientes
      set
        /* %SetFK(clientes,NULL) */
        clientes.country_code = NULL
      from clientes,deleted
      where
        /* %JoinFKPK(clientes,deleted," = "," and") */
        clientes.country_code = deleted.country_code
  end

  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* country R/16 client_machines ON PARENT UPDATE SET NULL */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
      CHILD_OWNER="", CHILD_TABLE="client_machines"
      P2C_VERB_PHRASE="R/16", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_16", FK_COLUMNS="country_code" */

  if
    /* %ParentPK(" or",update) */
    update(country_code)
  begin
    update client_machines
      set
        /* %SetFK(client_machines,NULL) */
        client_machines.country_code = NULL
      from client_machines,deleted
      where
        /* %JoinFKPK(client_machines,deleted," = "," and") */
        client_machines.country_code = deleted.country_code
  end

  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* country R/11 users ON PARENT UPDATE SET NULL */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="country"
      CHILD_OWNER="", CHILD_TABLE="users"
      P2C_VERB_PHRASE="R/11", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_11", FK_COLUMNS="country_code" */

  if
    /* %ParentPK(" or",update) */
    update(country_code)
  begin
    update users
      set
        /* %SetFK(users,NULL) */
        users.country_code = NULL
      from users,deleted
      where
        /* %JoinFKPK(users,deleted," = "," and") */
        users.country_code = deleted.country_code
  end


  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  return
error:
    raiserror (@errmsg,@errno,1) 
    rollback transaction
end

GO

Used By

216