21 lines
2.0 KiB
Transact-SQL
21 lines
2.0 KiB
Transact-SQL
/*
|
||
Run this script on SQL Server 2008 or later. There may be flaws if running on earlier versions of SQL Server.
|
||
*/
|
||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Expenditure2Expenditure]') AND type in (N'U'))
|
||
DROP TABLE [dbo].[Expenditure2Expenditure]
|
||
GO
|
||
CREATE TABLE [dbo].[Expenditure2Expenditure] (
|
||
[Id] [uniqueidentifier] NOT NULL,
|
||
[ParentId] [uniqueidentifier] NOT NULL,
|
||
[ChildId] [uniqueidentifier] NOT NULL,
|
||
[FactorType] [int] NULL,
|
||
[ProcessOrder] [int] NULL,
|
||
[FactorInt] [decimal](6, 3) NULL,
|
||
CONSTRAINT [PK_Expenditure2ExpenditureID] PRIMARY KEY CLUSTERED ([Id])
|
||
) ON [PRIMARY]
|
||
GO
|
||
ALTER TABLE [dbo].[Expenditure2Expenditure] ADD CONSTRAINT [FK_Child_ExpenditureCategory] FOREIGN KEY ([ChildId]) REFERENCES [dbo].[Expenditure_Category] ([Id])
|
||
GO
|
||
ALTER TABLE [dbo].[Expenditure2Expenditure] ADD CONSTRAINT [FK_Parent_ExpenditureCategory] FOREIGN KEY ([ParentId]) REFERENCES [dbo].[Expenditure_Category] ([Id])
|
||
GO
|