[dbo].[PlasticInstrument]
CREATE TABLE [dbo].[PlasticInstrument]
(
[InstrumentID] [int] NOT NULL IDENTITY(1, 1),
[ProviderFID] [int] NOT NULL,
[HolderName] [varchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillingAddress] [varchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillingCity] [varchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillingState] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillingPostalCode] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Token] [varchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Accessory] [varchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[LastFour] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[TokenTypeFID] [int] NOT NULL,
[CustomerNumber] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[OrderFID] [int] NULL,
[Inactive] [bit] NOT NULL CONSTRAINT [DF_PlasticInstrument_Inactive] DEFAULT ((0)),
[FirstUsedDate] [datetime] NOT NULL CONSTRAINT [DF_PlasticInstrument_FirstUsedDate] DEFAULT (getutcdate()),
[LastUsedDate] [datetime] NOT NULL CONSTRAINT [DF_PlasticInstrument_LastUsedDate] DEFAULT (getutcdate()),
[NickName] [varchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[OnlineOkForFutureInv] [bit] NOT NULL CONSTRAINT [DF_PlasticInstrument_OnlineOkForFutureInv] DEFAULT ((0)),
[OnlineOkDate] [datetime] NULL,
[HolderLastName] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillingCountry] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[GatewayCustomerID] [varchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BillingAddress2] [varchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ExpirationDate] [datetime] NULL,
[ConversionFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PlasticInstrument] ADD CONSTRAINT [PK_PlasticInstrument] PRIMARY KEY CLUSTERED ([InstrumentID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_PlasticInstrument_CustomerNumber] ON [dbo].[PlasticInstrument] ([CustomerNumber]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_PlasticInstrument_OrderFID] ON [dbo].[PlasticInstrument] ([OrderFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PlasticInstrument] ADD CONSTRAINT [FK_PlasticInstrument_OrderFID] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[PlasticInstrument] ADD CONSTRAINT [FK_PlasticInstrument_PlasticProviderFID] FOREIGN KEY ([ProviderFID]) REFERENCES [dbo].[PlasticProvider] ([ProviderID])
GO
ALTER TABLE [dbo].[PlasticInstrument] ADD CONSTRAINT [FK_PlasticInstrument_PlasticTokenTypeFID] FOREIGN KEY ([TokenTypeFID]) REFERENCES [dbo].[PlasticTokenType] ([TokenTypeID])
GO
GRANT SELECT ON [dbo].[PlasticInstrument] TO [MssExec]
GRANT INSERT ON [dbo].[PlasticInstrument] TO [MssExec]
GRANT DELETE ON [dbo].[PlasticInstrument] TO [MssExec]
GRANT UPDATE ON [dbo].[PlasticInstrument] TO [MssExec]
GO