22 lines
1.9 KiB
Transact-SQL
22 lines
1.9 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].[Rate]') AND type in (N'U'))
|
||
DROP TABLE [dbo].[Rate]
|
||
GO
|
||
CREATE TABLE [dbo].[Rate] (
|
||
[Id] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Rate_Id] DEFAULT (newid()),
|
||
[ParentId] [uniqueidentifier] NULL,
|
||
[ExpenditureCategoryId] [uniqueidentifier] NULL,
|
||
[Rate] [decimal](15, 4) NULL,
|
||
[StartDate] [datetime] NULL,
|
||
[EndDate] [datetime] NULL,
|
||
[FreezeRate] [int] NULL,
|
||
[Type] [smallint] NOT NULL CONSTRAINT [DF__Rate__TypeInt__7E37BEF6] DEFAULT ((0)),
|
||
[DerivedId] [uniqueidentifier] NULL,
|
||
CONSTRAINT [PK_RateID] PRIMARY KEY CLUSTERED ([Id])
|
||
) ON [PRIMARY]
|
||
GO
|
||
ALTER TABLE [dbo].[Rate] ADD CONSTRAINT [FK_Rate_ExpenditureCategory] FOREIGN KEY ([ExpenditureCategoryId]) REFERENCES [dbo].[Expenditure_Category] ([Id])
|
||
GO
|