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 10/29/2016 10:25:52 PM

Columns

22
Key Name Data Type Length Precision Scale Not Null Identity Rule Default Computed Persisted Description
doc_id int 4 10 0

True

False

False

name varchar 100 0 0

False

False

False

category varchar 100 0 0

False

False

False

title varchar 150 0 0

False

False

False

large_image_url varchar 250 0 0

False

False

False

body text 0 0

False

False

False

logo_url varchar 250 0 0

False

False

False

image_url varchar 250 0 0

False

False

False

abstract text 0 0

False

False

False

doc_date datetime 8 23 3

False

False

False

document_url varchar 250 0 0

False

False

False

url varchar 250 0 0

False

False

False

visible tinyint 1 3 0

False

False

False

created_by int 4 10 0

False

False

False

created datetime 8 23 3

False

False

False

modified_by int 4 10 0

False

False

False

modified datetime 8 23 3

False

False

False

template_default int 4 10 0

False

False

False

services_list varchar 100 0 0

False

False

False

requires_login tinyint 1 3 0

False

False

False

header varchar 250 0 0

False

False

False

caption varchar 500 0 0

False

False

False

Indexes

1
Key Name Columns Unique Type Description
PK__docs__0DAF0CB0 doc_id

True

Triggers

3
Name ANSI Nulls ON Quoted Identifier ON On Not For Replication Description
tD_docs

True

True

AFTER DELETE

False

tI_docs

True

True

AFTER INSERT

False

tU_docs

True

True

AFTER UPDATE

False

Foreign Keys

1
Name Columns Description
FK__docs__template_d__59FA5E80 template_id

SQL Script

Copy
CREATE TABLE dbo.docs (
  doc_id int NOT NULL,
  name varchar(100) NULL,
  category varchar(100) NULL,
  title varchar(150) NULL,
  large_image_url varchar(250) NULL,
  body text NULL,
  logo_url varchar(250) NULL,
  image_url varchar(250) NULL,
  abstract text NULL,
  doc_date datetime NULL,
  document_url varchar(250) NULL,
  url varchar(250) NULL,
  visible tinyint NULL,
  created_by int NULL,
  created datetime NULL,
  modified_by int NULL,
  modified datetime NULL,
  template_default int NULL,
  services_list varchar(100) NULL,
  requires_login tinyint NULL,
  header varchar(250) NULL,
  caption varchar(500) NULL,
  PRIMARY KEY NONCLUSTERED (doc_id) WITH (FILLFACTOR = 90)
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER trigger dbo.tD_docs on dbo.docs for DELETE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* DELETE trigger on docs */
begin
  declare  @errno   int,
           @errmsg  varchar(255)
    /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
    /* docs R/213 show_doc ON PARENT DELETE RESTRICT */
    /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="docs"
        CHILD_OWNER="", CHILD_TABLE="show_doc"
        P2C_VERB_PHRASE="R/213", C2P_VERB_PHRASE="R/213", 
        FK_CONSTRAINT="R_213", FK_COLUMNS="doc_id" */

    if exists (
      select * from deleted,show_doc
      where
        /*  %JoinFKPK(show_doc,deleted," = "," and") */
        show_doc.doc_id = deleted.doc_id
    )
    begin
      select @errno  = 30001,
             @errmsg = 'Cannot DELETE docs because show_doc 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_docs on dbo.docs for INSERT as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* INSERT trigger on docs */
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 */
  /* templates R/77 docs ON CHILD INSERT SET NULL */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="templates"
      CHILD_OWNER="", CHILD_TABLE="docs"
      P2C_VERB_PHRASE="R/77", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_77", FK_COLUMNS="template_default" */

  if
    /* %ChildFK(" or",update) */
    update(template_default)
  begin
    update docs
      set
        /* %SetFK(docs,NULL) */
        docs.template_default = NULL
      from docs,inserted
      where
        /* %JoinPKPK(docs,inserted," = "," and") */
  docs.doc_id = inserted.doc_id and
   
        not exists (
          select * from templates
          where
            /* %JoinFKPK(inserted,templates," = "," and") */
            inserted.template_default = templates.template_id
        )
  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_docs on dbo.docs for UPDATE as
/* ERwin Builtin Mon Oct 01 10:32:44 2007 */
/* UPDATE trigger on docs */
begin
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insdoc_id int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount
  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* docs R/213 show_doc ON PARENT UPDATE RESTRICT */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="docs"
      CHILD_OWNER="", CHILD_TABLE="show_doc"
      P2C_VERB_PHRASE="R/213", C2P_VERB_PHRASE="R/213", 
      FK_CONSTRAINT="R_213", FK_COLUMNS="doc_id" */

  if
    /* %ParentPK(" or",update) */
    update(doc_id)
  begin
    if exists (
      select * from deleted,show_doc
      where
        /*  %JoinFKPK(show_doc,deleted," = "," and") */
        show_doc.doc_id = deleted.doc_id
    )
    begin
      select @errno  = 30005,
             @errmsg = 'Cannot UPDATE docs because show_doc exists.'
      goto error
    end
  end

  /* ERwin Builtin Mon Oct 01 10:32:44 2007 */
  /* templates R/77 docs ON CHILD UPDATE SET NULL */
  /* ERWIN_RELATION:PARENT_OWNER="", PARENT_TABLE="templates"
      CHILD_OWNER="", CHILD_TABLE="docs"
      P2C_VERB_PHRASE="R/77", C2P_VERB_PHRASE="", 
      FK_CONSTRAINT="R_77", FK_COLUMNS="template_default" */

  if
    /* %ChildFK(" or",update) */
    update(template_default)
  begin
    update docs
      set
        /* %SetFK(docs,NULL) */
        docs.template_default = NULL
      from docs,inserted
      where
        /* %JoinPKPK(docs,inserted," = "," and") */
  docs.doc_id = inserted.doc_id and
   
        not exists (
          select * from templates
          where
            /* %JoinFKPK(inserted,templates," = "," and") */
            inserted.template_default = templates.template_id
        )
  end


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

GO

ALTER TABLE dbo.docs
  ADD FOREIGN KEY (template_default) REFERENCES dbo.templates (template_id)
GO

Depends On

3

Used By

53