使用SMO DependencyWalker

时间:2017-05-16 00:33:08

标签: c# sql-server smo

我有一个包含大量表的数据库,我使用SMO DependencyTree和DependencyWalker按依赖关系对它们进行排序,然后将它们编写出来。但是,有两个特定的表具有以下关系:

CREATE TABLE Production_Events (
    Event_Id int identity(1,1) NOT NULL,
    Start_Time datetime NOT NULL,
    End_Time datetime null
    --... other columns
)

CREATE TABLE Production_Event_Data (
    Production_Event_Data_Id int identity(1,1) NOT NULL,
    Event_Id int NOT NULL, -- Foreign key to the above table
    Variable_Id int NOT NULL, -- Foreign key to another table
    Variable_Value varchar(25) NULL
    --... other columns
)

Production_Event表有一个FOR INSERT触发器,当在Production_Event中插入新行时,该触发器使用来自各种源的值填充Production_Event_Data表。

如果Production_Event表上没有触发器,则DependencyWalker将通过检测这些表之间的外键关系来正确地对这些表进行排序。但是,如果存在触发器,则DependencyWalker将触发器视为依赖项,并通过将Production_Event_Data表放在Production_Events之前错误地对表进行排序。如果您尝试执行脚本,最终会以外键约束错误结束。

有没有办法将DependencyWalker配置为只考虑表依赖项而不是触发依赖项?

0 个答案:

没有答案