CREATE TABLE [dbo].[ShAttributeValues]
(
[ShAttributeValueID] [int] NOT NULL IDENTITY(1, 1),
[ShAttributeID] [int] NOT NULL,
[ShTrackingValueGroupID] [int] NOT NULL,
[IDVal] [int] NULL,
[Textval] [varchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[IsActive] [bit] NOT NULL CONSTRAINT [DF_ShAttributeValues_IsActive] DEFAULT ((1)),
[Required] [bit] NOT NULL CONSTRAINT [DF_ShAttributeValues_Required] DEFAULT ((0)),
[CreatorID] [varchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[CreateDate] [datetime] NOT NULL CONSTRAINT [DF_ShAttributeValues_CreateDate] DEFAULT (getdate()),
[MeterReadingGroupID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ShAttributeValues] ADD CONSTRAINT [PK_ShAttributeValues] PRIMARY KEY CLUSTERED ([ShAttributeValueID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ShAttributeValues] ADD CONSTRAINT [FK_ShAttributeValues_MeterReadingGroupID_MTMeterReadingGroups] FOREIGN KEY ([MeterReadingGroupID]) REFERENCES [dbo].[MTMeterReadingGroups] ([MeterReadingGroupID])
GO
ALTER TABLE [dbo].[ShAttributeValues] ADD CONSTRAINT [FK_ShAttributeValues_ShAttributeID_ShAttributes] FOREIGN KEY ([ShAttributeID]) REFERENCES [dbo].[ShAttributes] ([ShAttributeID])
GO
ALTER TABLE [dbo].[ShAttributeValues] ADD CONSTRAINT [FK_ShAttributeValues_ShTrackingValueGroupID_ShTrackingValueGroups] FOREIGN KEY ([ShTrackingValueGroupID]) REFERENCES [dbo].[ShTrackingValueGroups] ([ShTrackingValueGroupID])
GO