dbo.informe_valores_historico

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:34 PM
Last Modified 4/2/2016 11:03:12 PM

Columns

7
Key Name Data Type Length Precision Scale Not Null Identity Rule Default Computed Persisted Description
fecha_hora datetime 8 23 3

True

False

False

valor varchar 512 0 0

False

False

False

modificado_por int 4 10 0

False

False

False

modificado_fecha datetime 8 23 3

False

False

False

informe int 4 10 0

True

False

False

nombre_variable varchar 200 0 0

True

False

False

instancia tinyint 1 3 0

True

False

False

Indexes

1
Key Name Columns Unique Type Description
PK__informe_valores___22AA2996 informe, nombre_variable, instancia, fecha_hora

True

Triggers

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

True

True

AFTER INSERT

False

tU_informe_valores_historico

True

True

AFTER UPDATE

False

Foreign Keys

1
Name Columns Description
FK__informe_valores___6477ECF3 informe, nombre_variable, instancia

SQL Script

Copy
CREATE TABLE dbo.informe_valores_historico (
  fecha_hora datetime NOT NULL,
  valor varchar(512) NULL,
  modificado_por int NULL,
  modificado_fecha datetime NULL,
  informe int NOT NULL,
  nombre_variable varchar(200) NOT NULL,
  instancia tinyint NOT NULL,
  PRIMARY KEY NONCLUSTERED (informe, nombre_variable, instancia, fecha_hora) WITH (FILLFACTOR = 90)
)
ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER trigger dbo.tI_informe_valores_historico on dbo.informe_valores_historico for INSERT as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* INSERT trigger on informe_valores_historico */
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 */
  /* informe_valores R/268 informe_valores_historico ON CHILD INSERT RESTRICT */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="informe_valores"
      CHILD_OWNER="", CHILD_TABLE="informe_valores_historico"
      P2C_VERB_PHRASE="R/268", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_268", FK_COLUMNS="informe""nombre_variable""instancia" */

  if
    /* %ChildFK(" or",update) */
    update(informe) or
    update(nombre_variable) or
    update(instancia)
  begin
    select @nullcnt = 0
    select @validcnt = count(*)
      from inserted,informe_valores
        where
          /* %JoinFKPK(inserted,informe_valores) */
          inserted.informe = informe_valores.informe and
          inserted.nombre_variable = informe_valores.nombre_variable and
          inserted.instancia = informe_valores.instancia
    /* %NotnullFK(inserted," is null","select @nullcnt = count(*) from inserted where"," and") */
    
    if @validcnt + @nullcnt != @numrows
    begin
      select @errno  = 30002,
             @errmsg = 'Cannot INSERT informe_valores_historico because informe_valores does not exist.'
      goto error
    end
  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_informe_valores_historico on dbo.informe_valores_historico for UPDATE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* UPDATE trigger on informe_valores_historico */
begin
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insinforme int, 
           @insnombre_variable varchar(200), 
           @insinstancia tinyint, 
           @insfecha_hora datetime,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount
  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* informe_valores R/268 informe_valores_historico ON CHILD UPDATE RESTRICT */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="informe_valores"
      CHILD_OWNER="", CHILD_TABLE="informe_valores_historico"
      P2C_VERB_PHRASE="R/268", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_268", FK_COLUMNS="informe""nombre_variable""instancia" */

  if
    /* %ChildFK(" or",update) */
    update(informe) or
    update(nombre_variable) or
    update(instancia)
  begin
    select @nullcnt = 0
    select @validcnt = count(*)
      from inserted,informe_valores
        where
          /* %JoinFKPK(inserted,informe_valores) */
          inserted.informe = informe_valores.informe and
          inserted.nombre_variable = informe_valores.nombre_variable and
          inserted.instancia = informe_valores.instancia
    /* %NotnullFK(inserted," is null","select @nullcnt = count(*) from inserted where"," and") */
    
    if @validcnt + @nullcnt != @numrows
    begin
      select @errno  = 30007,
             @errmsg = 'Cannot UPDATE informe_valores_historico because informe_valores does not exist.'
      goto error
    end
  end


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

GO

ALTER TABLE dbo.informe_valores_historico
  ADD FOREIGN KEY (informe, nombre_variable, instancia) REFERENCES dbo.informe_valores (informe, nombre_variable, instancia)
GO

Depends On

2