· 8 years ago · Feb 09, 2018, 05:56 PM
1and this one too
2
3USE [CLARA]
4GO
5
6IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[lcr].[FK_ClaraFlow_Bucket_BucketId]') AND parent_object_id = OBJECT_ID(N'[lcr].[ClaraFlow]'))
7ALTER TABLE [lcr].[ClaraFlow] DROP CONSTRAINT [FK_ClaraFlow_Bucket_BucketId]
8GO
9
10IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[lcr].[FK_Deal_ClaraFlow]') AND parent_object_id = OBJECT_ID(N'[lcr].[ClaraFlow]'))
11ALTER TABLE [lcr].[ClaraFlow] DROP CONSTRAINT [FK_Deal_ClaraFlow]
12GO
13
14IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[lcr].[FK_RefAsset_ClaraFlow_AssetId]') AND parent_object_id = OBJECT_ID(N'[lcr].[ClaraFlow]'))
15ALTER TABLE [lcr].[ClaraFlow] DROP CONSTRAINT [FK_RefAsset_ClaraFlow_AssetId]
16GO
17
18IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[lcr].[FK_RefFlowType_ClaraFlow]') AND parent_object_id = OBJECT_ID(N'[lcr].[ClaraFlow]'))
19ALTER TABLE [lcr].[ClaraFlow] DROP CONSTRAINT [FK_RefFlowType_ClaraFlow]
20GO
21
22USE [CLARA]
23GO
24
25/****** Object: Table [lcr].[ClaraFlow] Script Date: 02/09/2018 12:33:33 ******/
26IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[lcr].[ClaraFlow]') AND type in (N'U'))
27DROP TABLE [lcr].[ClaraFlow]
28GO
29
30USE [CLARA]
31GO
32
33/****** Object: Table [lcr].[ClaraFlow] Script Date: 02/09/2018 12:33:33 ******/
34SET ANSI_NULLS ON
35GO
36
37SET QUOTED_IDENTIFIER ON
38GO
39
40CREATE TABLE [lcr].[ClaraFlow](
41 [ClaraFlowId] [bigint] IDENTITY(1,1) NOT NULL,
42 [DealId] [bigint] NOT NULL,
43 [FlowDate] [datetime] NOT NULL,
44 [Amount] [float] NOT NULL,
45 [FlowTypeId] [int] NOT NULL,
46 [IsInsured] [bit] NOT NULL,
47 [BucketId] [int] NOT NULL,
48 [IsEncumbered] [bit] NOT NULL,
49 [SequenceId] [int] NULL,
50 [AssetId] [int] NOT NULL,
51 [CadAmount] [float] NOT NULL,
52 CONSTRAINT [PK_ClaraFlow_ClaraFlowId] PRIMARY KEY CLUSTERED
53(
54 [ClaraFlowId] ASC
55)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
56) ON [PRIMARY]
57
58GO
59
60ALTER TABLE [lcr].[ClaraFlow] WITH CHECK ADD CONSTRAINT [FK_ClaraFlow_Bucket_BucketId] FOREIGN KEY([BucketId])
61REFERENCES [rpt].[Bucket] ([BucketId])
62GO
63
64ALTER TABLE [lcr].[ClaraFlow] CHECK CONSTRAINT [FK_ClaraFlow_Bucket_BucketId]
65GO
66
67ALTER TABLE [lcr].[ClaraFlow] WITH NOCHECK ADD CONSTRAINT [FK_Deal_ClaraFlow] FOREIGN KEY([DealId])
68REFERENCES [lcr].[Deal] ([DealId])
69GO
70
71ALTER TABLE [lcr].[ClaraFlow] CHECK CONSTRAINT [FK_Deal_ClaraFlow]
72GO
73
74ALTER TABLE [lcr].[ClaraFlow] WITH CHECK ADD CONSTRAINT [FK_RefAsset_ClaraFlow_AssetId] FOREIGN KEY([AssetId])
75REFERENCES [lcr].[RefAsset] ([AssetId])
76GO
77
78ALTER TABLE [lcr].[ClaraFlow] CHECK CONSTRAINT [FK_RefAsset_ClaraFlow_AssetId]
79GO
80
81ALTER TABLE [lcr].[ClaraFlow] WITH NOCHECK ADD CONSTRAINT [FK_RefFlowType_ClaraFlow] FOREIGN KEY([FlowTypeId])
82REFERENCES [lcr].[RefFlowType] ([FlowTypeId])
83GO
84
85ALTER TABLE [lcr].[ClaraFlow] CHECK CONSTRAINT [FK_RefFlowType_ClaraFlow]
86GO
87
88
89
90
91Julie could you send me this query ^
92
93
94
95USE [CLARA]
96GO
97
98IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[lcr].[FK_Bucket_ClaraFlowReportLink]') AND parent_object_id = OBJECT_ID(N'[lcr].[ClaraFlowReportLink]'))
99ALTER TABLE [lcr].[ClaraFlowReportLink] DROP CONSTRAINT [FK_Bucket_ClaraFlowReportLink]
100GO
101
102IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[lcr].[FK_ClaraFlowReportLink_ClaraFlow_ClaraFlowId]') AND parent_object_id = OBJECT_ID(N'[lcr].[ClaraFlowReportLink]'))
103ALTER TABLE [lcr].[ClaraFlowReportLink] DROP CONSTRAINT [FK_ClaraFlowReportLink_ClaraFlow_ClaraFlowId]
104GO
105
106IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[lcr].[FK_ClaraFlowReportLink_DapLine_DapLineId]') AND parent_object_id = OBJECT_ID(N'[lcr].[ClaraFlowReportLink]'))
107ALTER TABLE [lcr].[ClaraFlowReportLink] DROP CONSTRAINT [FK_ClaraFlowReportLink_DapLine_DapLineId]
108GO
109
110IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[lcr].[FK_ClaraFlowReportLink_ImageId_Image_ImageId]') AND parent_object_id = OBJECT_ID(N'[lcr].[ClaraFlowReportLink]'))
111ALTER TABLE [lcr].[ClaraFlowReportLink] DROP CONSTRAINT [FK_ClaraFlowReportLink_ImageId_Image_ImageId]
112GO
113
114USE [CLARA]
115GO
116
117/****** Object: Table [lcr].[ClaraFlowReportLink] Script Date: 02/09/2018 12:33:49 ******/
118IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[lcr].[ClaraFlowReportLink]') AND type in (N'U'))
119DROP TABLE [lcr].[ClaraFlowReportLink]
120GO
121
122USE [CLARA]
123GO
124
125/****** Object: Table [lcr].[ClaraFlowReportLink] Script Date: 02/09/2018 12:33:49 ******/
126SET ANSI_NULLS ON
127GO
128
129SET QUOTED_IDENTIFIER ON
130GO
131
132CREATE TABLE [lcr].[ClaraFlowReportLink](
133 [ClaraFlowReportLinkId] [bigint] IDENTITY(1,1) NOT NULL,
134 [ClaraFlowId] [bigint] NOT NULL,
135 [DapLineId] [int] NOT NULL,
136 [ImageId] [int] NOT NULL,
137 [BucketId] [int] NOT NULL,
138 [IsGreater30] [bit] NOT NULL,
139 [Delta] [float] NOT NULL,
140 [CadDelta] [float] NOT NULL,
141 CONSTRAINT [PK_ClaraFlowReportLink_ClaraFlowReportLinkId] PRIMARY KEY CLUSTERED
142(
143 [ClaraFlowReportLinkId] ASC
144)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
145) ON [PRIMARY]
146
147GO
148
149ALTER TABLE [lcr].[ClaraFlowReportLink] WITH NOCHECK ADD CONSTRAINT [FK_Bucket_ClaraFlowReportLink] FOREIGN KEY([BucketId])
150REFERENCES [rpt].[Bucket] ([BucketId])
151GO
152
153ALTER TABLE [lcr].[ClaraFlowReportLink] CHECK CONSTRAINT [FK_Bucket_ClaraFlowReportLink]
154GO
155
156ALTER TABLE [lcr].[ClaraFlowReportLink] WITH NOCHECK ADD CONSTRAINT [FK_ClaraFlowReportLink_ClaraFlow_ClaraFlowId] FOREIGN KEY([ClaraFlowId])
157REFERENCES [lcr].[ClaraFlow] ([ClaraFlowId])
158GO
159
160ALTER TABLE [lcr].[ClaraFlowReportLink] CHECK CONSTRAINT [FK_ClaraFlowReportLink_ClaraFlow_ClaraFlowId]
161GO
162
163ALTER TABLE [lcr].[ClaraFlowReportLink] WITH NOCHECK ADD CONSTRAINT [FK_ClaraFlowReportLink_DapLine_DapLineId] FOREIGN KEY([DapLineId])
164REFERENCES [rpt].[DapLine] ([DapLineId])
165GO
166
167ALTER TABLE [lcr].[ClaraFlowReportLink] CHECK CONSTRAINT [FK_ClaraFlowReportLink_DapLine_DapLineId]
168GO
169
170ALTER TABLE [lcr].[ClaraFlowReportLink] WITH NOCHECK ADD CONSTRAINT [FK_ClaraFlowReportLink_ImageId_Image_ImageId] FOREIGN KEY([ImageId])
171REFERENCES [lcr].[Image] ([ImageId])
172GO
173
174ALTER TABLE [lcr].[ClaraFlowReportLink] CHECK CONSTRAINT [FK_ClaraFlowReportLink_ImageId_Image_ImageId]
175GO