我准备将数据从现有表移动到一组新表。我继承的旧表不断增长(在列中),这是新的 集合是为了适应增长而开发的。此数据移动会将已输入旧表格的数据移动到新系统中。桌子。
我已经提出了一个粗略的逻辑计划和一些代码,但是,由于我对SQL Server中的这些内容非常陌生,我感谢输入和最好的帮助 行动方针。
这是我的基本大纲,不一定是语法上的正确(由于我的经验不足),但它有助于说明所需的步骤。是否可以在一个循环中完成此大纲中的所有操作,或者我是否需要将其分解为更小的操作?
一个。获取Obj_Out_Old.CourseID并放入Objectives.CourseID
湾获取Obj_Out_Old.Objective并将其放入Objectives.Objective
℃。循环结果列 - 开始
- 课程年度和课程学期的说明:
- 检查Obj_Out_Old.CourseID中的年份(最后2位数 - 例如" 79991208",其中" 08"表示" 2008"),
- 检查Obj_Out_Old.CourseID中的学期(第6位 - 例如,如果它等于" 1"然后"跌倒",如果它等于" 2"然后"春天")
- 查看从Outcomes表中获得的OutcomeID。
- 获取OutcomeYear和OutcomeSemester(下方)的代码:
--If (CourseID year = 2002 and CourseID semester = 'fall') OR (CourseID year > 2002 and CourseID year < 2004) OR (CourseID year = 2004 and
CourseID semester = 'spring')
--...translated....
If ((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) = 02) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),6,1) = 1))
OR
((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) > 02) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) < 04))
OR
((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) = 04) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),6,1) = 2))
Then
@OutcomeYear='2002'
@OutcomeSemester='fall'
End If
--If (CourseID year = 2004 and CourseID semester = 'fall') OR (CourseID year > 2004 and CourseID year < 2008) OR (CourseID year = 2007 and CourseID semester =
'fall')
--...translated....
If ((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) = 04) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),6,1) = 1))
OR
((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) > 04) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) < 08))
OR
((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) = 07) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),6,1) = 1))
Then
@OutcomeYear='2004'
@OutcomeSemester='fall'
End If
--If (CourseID year = 2008 and CourseID semester = 'spring') OR (CourseID year = 2008 and CourseID semester = 'fall') OR (CourseID year > 2008 and CourseID
year < 2011) OR (CourseID year = 2011 and CourseID
--semester = 'spring')
--...translated....
If ((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) = 08) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),6,1) = 2))
OR
((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) = 08) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),6,1) = 1))
OR
((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) > 08) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) < 11))
OR
((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) = 11) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),6,1) = 2))
Then
@OutcomeYear='2008'
@OutcomeSemester='spring'
End If
--If (CourseID year = 2011 and CourseID semester = 'fall') OR (CourseID year > 2011 and CourseID year < 2013) OR (CourseID year = 2013 and CourseID semester =
'spring')
--...translated....
If ((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) = 11) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),6,1) = 1))
OR
((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) > 11) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) < 13))
OR
((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) = 13) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),6,1) = 2))
Then
@OutcomeYear='2011'
@OutcomeSemester='fall'
End If
--If (CourseID year = 2013 and CourseID semester = 'fall') OR (CourseID year > 2013 and CourseID year < 2015) OR (CourseID year = 2015 and CourseID semester =
'spring')
--...translated....
If ((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) = 13) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),6,1) = 1))
OR
((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) > 13) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) < 15))
OR
((CAST(SUBSTRING(CAST(CourseID AS VARCHAR),7,2) AS INT) = 15) AND (CAST(SUBSTRING(CAST(CourseID AS VARCHAR),6,1) = 2))
Then
@OutcomeYear='2013'
@OutcomeSemester='fall'
End If
- 一旦找到结果集, - 使用Outcomes.OutcomeNumber匹配列名中的结果编号(来自Obj_Out_Old表)
- 列名中的结果编号说明(来自Obj_Out_Old表): - 如果列名有&#34; _a&#34;在标题中,它被归类为OutcomeType&#34; General&#34;在结果表中。 - 例如,列Obj_Out_Old.Out1_a将是Outcomes.OutcomeType =&#34; General&#34;,Outcomes.OutcomeNumber =&#34; 1&#34; - 那么,&#34; _a&#34;后缀被删除(不会转移到新表)
Get Outcome Number (in the Column Name, e.g. "Out1" with "1" being the Outcome Number)
@Old_Table_Outcome_Number=[Outcome Number from column name]
~~~~~~~
If (no '_a' in the column title) AND ((@OutcomeYear='2002' AND @OutcomeSemester='fall') OR (@OutcomeYear='2004' AND @OutcomeSemester='fall') OR
(@OutcomeYear='2008' AND @OutcomeSemester='spring') OR
(@OutcomeYear='2011' AND @OutcomeSemester='fall') OR (@OutcomeYear='2013' AND @OutcomeSemester='fall'))
Then
@OutcomeType='Specific'
Else If ('_a' in the column title) AND (@OutcomeYear='2008' AND @OutcomeSemester='spring')
Then
@OutcomeType='General'
End If
~~~~~~~
-
--get Outcomes.ID
Select * from Outcomes
WHERE
Outcomes.OutcomeNumber=@Old_Table_Outcome_Number
AND
Outcomes.OutcomeVersionYear=@OutcomeYear
AND
Outcomes.OutcomeVersionSemester=@OutcomeSemester
AND
Outcomes.OutcomeType=@OutcomeType
-
--Get Outcome Value
Get Outcome Value from Obj_Out_Old.[Current Outcome Column]
@Old_Table_Outcome_Value=Obj_Out_Old.[Current Outcome Column]
If (the column does not have "P" as the 4th character in the column name, AND the column's value has either "N" "C" "P" or "N/A" values)
Then
@NonPriorityVar=@Old_Table_Outcome_Value
End If
If (the column has "P" as the 4th character in the column name AND the column's value has either 0 or 1)
Then
@PriorityVar='Priority'
d。将Outcomes.OutcomeID放入Obj_Out表
即获取Objectives.ID(从步骤a和b)并放入Obj_Out(与步骤d相同的行)。
F。获取Obj_Out.ID(来自步骤d中的行)。
克。获得结果值(来自第4步) 并匹配NCP表。
If @NonPriorityVar <> '' then
Select ID from NCP
WHERE
NCP_Descr=@NonPriorityVar
End If
--...or NCP_Priority table
If @PriorityVar<>'' then
Select ID FROM NCP_Priority
WHERE
NCP_Priority_Desc=@PriorityVar
End If
小时。将NCP.ID放入NCP_Out.NCP_ID
我。如果Outcomes表格行的优先级为&#34; true,&#34;然后 将NCP_Priority.ID(其中NCP_Priority.Description =&#34; true&#34; - 从步骤8a。)放入 NCP_Out。
Priority_ID = NCP_Priority.ID(来自步骤g。)
NCP_Out.NCP_Priority_Value =&#34;真&#34;
Ĵ。放入Obj_Out.ID(从第6步开始) 进入NCP_Out.ObjOutID
ķ。对Obj_Out_Old表的下一行重复上述过程。
表格编写脚本(如下):
--The existing table (ObjOut_Old) -
--I've included several rows of sample data, to illustrate:
--==================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Obj_Out_Old](
[ID] [int] IDENTITY(1,1) NOT NULL,
[CourseID] [int] NOT NULL,
[Objective] [text] NULL,
[Out1] [varchar](20) NULL,
[Out2] [varchar](20) NULL,
[Out3] [varchar](20) NULL,
[Out4] [varchar](20) NULL,
[Out5] [varchar](20) NULL,
[Out6] [varchar](20) NULL,
[Out7] [varchar](20) NULL,
[Out8] [varchar](20) NULL,
[Out9] [varchar](20) NULL,
[Out10] [varchar](20) NULL,
[Out11] [varchar](20) NULL,
[Out12] [varchar](20) NULL,
[Out13] [varchar](20) NULL,
[Out14] [varchar](20) NULL,
[Out15] [varchar](20) NULL,
[OutP1] [bit] NULL,
[OutP2] [bit] NULL,
[OutP3] [bit] NULL,
[OutP4] [bit] NULL,
[OutP5] [bit] NULL,
[OutP6] [bit] NULL,
[OutP7] [bit] NULL,
[OutP8] [bit] NULL,
[OutP9] [bit] NULL,
[OutP10] [bit] NULL,
[OutP11] [bit] NULL,
[OutP12] [bit] NULL,
[OutP13] [bit] NULL,
[OutP14] [bit] NULL,
[OutP15] [bit] NULL,
[Out1_a] [varchar](20) NULL,
[Out2_a] [varchar](20) NULL,
[Out3_a] [varchar](20) NULL,
[OutP1_a] [bit] NULL,
[OutP2_a] [bit] NULL,
[OutP3_a] [bit] NULL,
[LastUpdate] [datetime] NULL,
[Date_Created] [datetime] NULL,
CONSTRAINT [PK_Obj_Out_Old] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[Obj_Out_Old] ON
INSERT [dbo].[Obj_Out_Old] ([ID], [CourseID], [Objective], [Out1], [Out2], [Out3], [Out4], [Out5], [Out6], [Out7], [Out8], [Out9], [Out10], [Out11], [Out12],
[Out13], [Out14], [Out15], [OutP1], [OutP2], [OutP3], [OutP4], [OutP5], [OutP6], [OutP7], [OutP8], [OutP9], [OutP10], [OutP11], [OutP12], [OutP13], [OutP14],
[OutP15], [Out1_a], [Out2_a], [Out3_a], [OutP1_a], [OutP2_a], [OutP3_a], [LastUpdate], [Date_Created]) VALUES (26, 78442304, N'Identifies', N'C', N'C', N'N/A',
N'N/A', N'N/A', N'N/A', N'N/A', N'N/A', N'N/A', N'N/A', N'N/A', N'N/A', N'N/A', N'N/A', N'N/A', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, N'N/A', N'N/A',
N'N/A', 0, 0, 0, CAST(0x000095FC00F61800 AS DateTime), NULL)
INSERT [dbo].[Obj_Out_Old] ([ID], [CourseID], [Objective], [Out1], [Out2], [Out3], [Out4], [Out5], [Out6], [Out7], [Out8], [Out9], [Out10], [Out11], [Out12],
[Out13], [Out14], [Out15], [OutP1], [OutP2], [OutP3], [OutP4], [OutP5], [OutP6], [OutP7], [OutP8], [OutP9], [OutP10], [OutP11], [OutP12], [OutP13], [OutP14],
[OutP15], [Out1_a], [Out2_a], [Out3_a], [OutP1_a], [OutP2_a], [OutP3_a], [LastUpdate], [Date_Created]) VALUES (117, 77132204, N'Develop', N'N', N'N', N'N', N'N',
N'N', N'N/A', N'N/A', N'N', N'N/A', N'N', N'N/A', N'N', N'N/A', N'N', N'N/A', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL,
CAST(0x000095FE00EA8EE0 AS DateTime), NULL)
INSERT [dbo].[Obj_Out_Old] ([ID], [CourseID], [Objective], [Out1], [Out2], [Out3], [Out4], [Out5], [Out6], [Out7], [Out8], [Out9], [Out10], [Out11], [Out12],
[Out13], [Out14], [Out15], [OutP1], [OutP2], [OutP3], [OutP4], [OutP5], [OutP6], [OutP7], [OutP8], [OutP9], [OutP10], [OutP11], [OutP12], [OutP13], [OutP14],
[OutP15], [Out1_a], [Out2_a], [Out3_a], [OutP1_a], [OutP2_a], [OutP3_a], [LastUpdate], [Date_Created]) VALUES (123, 78422204, N'Strengthen', N'N/A', N'C', N'N',
N'N', N'C', N'C', N'C', N'', N'', N'N/A', N'C', N'N/A', N'C', N'N', N'N/A', 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, CAST
(0x000095FE00F58B60 AS DateTime), NULL)
INSERT [dbo].[Obj_Out_Old] ([ID], [CourseID], [Objective], [Out1], [Out2], [Out3], [Out4], [Out5], [Out6], [Out7], [Out8], [Out9], [Out10], [Out11], [Out12],
[Out13], [Out14], [Out15], [OutP1], [OutP2], [OutP3], [OutP4], [OutP5], [OutP6], [OutP7], [OutP8], [OutP9], [OutP10], [OutP11], [OutP12], [OutP13], [OutP14],
[OutP15], [Out1_a], [Out2_a], [Out3_a], [OutP1_a], [OutP2_a], [OutP3_a], [LastUpdate], [Date_Created]) VALUES (124, 78422204, N'develop', N'', N'C', N'C', N'C',
N'C', N'C', N'N/A', N'C', N'C', N'N/A', N'C', N'N/A', N'N/A', N'C', N'C', 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, CAST
(0x000095FE00F5D1B0 AS DateTime), NULL)
INSERT [dbo].[Obj_Out_Old] ([ID], [CourseID], [Objective], [Out1], [Out2], [Out3], [Out4], [Out5], [Out6], [Out7], [Out8], [Out9], [Out10], [Out11], [Out12],
[Out13], [Out14], [Out15], [OutP1], [OutP2], [OutP3], [OutP4], [OutP5], [OutP6], [OutP7], [OutP8], [OutP9], [OutP10], [OutP11], [OutP12], [OutP13], [OutP14],
[OutP15], [Out1_a], [Out2_a], [Out3_a], [OutP1_a], [OutP2_a], [OutP3_a], [LastUpdate], [Date_Created]) VALUES (127, 78242204, N'concepts', N'C', N'C', N'N/A',
N'N/A', N'C', N'N/A', N'C', N'C', N'C', N'N/A', N'N/A', N'N/A', N'N/A', N'N', N'N/A', 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL,
NULL, CAST(0x000095FF008D2CA0 AS DateTime), NULL)
SET IDENTITY_INSERT [dbo].[Obj_Out_Old] OFF
/****** Object: Default [DF__AMS_Conte__Date___3AC340F7] Script Date: 05/16/2014 12:03:31 ******/
ALTER TABLE [dbo].[Obj_Out_Old] ADD CONSTRAINT [DF__AMS_Conte__Date___3AC340F7] DEFAULT (getdate()) FOR [Date_Created]
GO
/****** Object: ForeignKey [FK_Obj_Out_Old_AMS_Courses] Script Date: 05/16/2014 12:03:31 ******/
ALTER TABLE [dbo].[Obj_Out_Old] WITH NOCHECK ADD CONSTRAINT [FK_Obj_Out_Old_AMS_Courses] FOREIGN KEY([CourseID])
REFERENCES [dbo].[AMS_Courses] ([CourseID])
ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[Obj_Out_Old] CHECK CONSTRAINT [FK_Obj_Out_Old_AMS_Courses]
GO
--///////////////////
--The new tables (6):
--//////////////////
/****** Object: Table [dbo].[Objectives] Script Date: 05/12/2014 10:27:23 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Objectives](
[ID] [int] IDENTITY(1,1) NOT NULL,
[CourseID] [int] NOT NULL,
[Objective] [varchar](max) NULL,
[LastUpdate] [datetime] NULL,
[Date_Created] [datetime] NULL,
CONSTRAINT [PK_Objectives] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[Objectives] WITH NOCHECK ADD CONSTRAINT [FK_Objectives_AMS_Courses] FOREIGN KEY([CourseID])
REFERENCES [dbo].[AMS_Courses] ([CourseID])
ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[Objectives] CHECK CONSTRAINT [FK_Objectives_AMS_Courses]
GO
ALTER TABLE [dbo].[Objectives] ADD CONSTRAINT [DF_Objectives_Date_Created] DEFAULT (getdate()) FOR [Date_Created]
GO
/////////////
/****** Object: Table [dbo].[Outcomes] Script Date: 05/12/2014 10:27:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Outcomes](
[ID] [int] IDENTITY(1,1) NOT NULL,
[OutcomeGroup] [varchar](50) NULL,
[OutcomeType] [varchar](50) NULL,
[OutcomeNumber] [int] NULL,
[OutcomeName] [varchar](500) NULL,
[OutcomeDescription] [varchar](max) NULL,
[OutcomeVersionYear] [varchar](50) NULL,
[OutcomeVersionSemester] [varchar](50) NULL,
[LastUpdate] [datetime] NULL,
[Date_Created] [datetime] NULL,
CONSTRAINT [PK_Outcomes] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[Outcomes] ADD CONSTRAINT [DF_Outcomes_Date_Created] DEFAULT (getdate()) FOR [Date_Created]
GO
/////////////
/****** Object: Table [dbo].[Obj_Out] Script Date: 05/12/2014 10:27:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Obj_Out](
[ID] [int] IDENTITY(1,1) NOT NULL,
[ObjectiveID] [int] NULL,
[OutcomeID] [int] NULL,
[LastUpdate] [datetime] NULL,
[Date_Created] [datetime] NULL,
CONSTRAINT [PK_Obj_Out] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Obj_Out] WITH CHECK ADD CONSTRAINT [FK_Obj_Out_Objectives] FOREIGN KEY([ObjectiveID])
REFERENCES [dbo].[Objectives] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Obj_Out] CHECK CONSTRAINT [FK_Obj_Out_Objectives]
GO
ALTER TABLE [dbo].[Obj_Out] WITH CHECK ADD CONSTRAINT [FK_Obj_Out_Outcomes] FOREIGN KEY([OutcomeID])
REFERENCES [dbo].[Outcomes] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Obj_Out] CHECK CONSTRAINT [FK_Obj_Out_Outcomes]
GO
ALTER TABLE [dbo].[Obj_Out] ADD CONSTRAINT [DF_Obj_Out_Date_Created] DEFAULT (getdate()) FOR [Date_Created]
GO
/////////////
/****** Object: Table [dbo].[NCP_Out] Script Date: 05/12/2014 10:32:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[NCP_Out](
[ID] [int] IDENTITY(1,1) NOT NULL,
[ObjOutID] [int] NOT NULL,
[NCP_ID] [int] NULL,
[NCP_Value] [bit] NULL,
[LastUpdate] [datetime] NULL,
[Date_Created] [datetime] NULL,
CONSTRAINT [PK_NCP_Out] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[NCP_Out] WITH CHECK ADD CONSTRAINT [FK_NCP_Out_NCP] FOREIGN KEY([NCP_ID])
REFERENCES [dbo].[NCP] ([ID])
GO
ALTER TABLE [dbo].[NCP_Out] CHECK CONSTRAINT [FK_NCP_Out_NCP]
GO
ALTER TABLE [dbo].[NCP_Out] WITH CHECK ADD CONSTRAINT [FK_NCP_Out_Obj_Out] FOREIGN KEY([ObjOutID])
REFERENCES [dbo].[Obj_Out] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[NCP_Out] CHECK CONSTRAINT [FK_NCP_Out_Obj_Out]
GO
ALTER TABLE [dbo].[NCP_Out] ADD CONSTRAINT [DF_NCP_Out_Date_Created] DEFAULT (getdate()) FOR [Date_Created]
GO
/////////////
/****** Object: Table [dbo].[NCP] Script Date: 05/12/2014 10:26:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[NCP](
[ID] [int] IDENTITY(1,1) NOT NULL,
[NCP_Descr] [varchar](max) NOT NULL,
[LastUpdate] [datetime] NULL,
[Date_Created] [datetime] NULL,
CONSTRAINT [PK_NCP] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[NCP] ADD CONSTRAINT [DF_NCP_Date_Created] DEFAULT (getdate()) FOR [Date_Created]
GO
///////////
/****** Object: Table [dbo].[NCP_Priority] Script Date: 05/13/2014 17:16:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[NCP_Priority](
[ID] [int] IDENTITY(1,1) NOT NULL,
[NCP_Priority_Descr] [varchar](max) NOT NULL,
[LastUpdate] [datetime] NULL,
[Date_Created] [datetime] NULL,
CONSTRAINT [PK_NCP_Priority] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[NCP_Priority] ADD CONSTRAINT [DF_NCP_Priority_Date_Created] DEFAULT (getdate()) FOR [Date_Created]
GO