[dbo].[ServiceDetailOrderMap]
CREATE TABLE [dbo].[ServiceDetailOrderMap]
(
[ServiceDetailOrderMapID] [int] NOT NULL IDENTITY(1, 1),
[ServiceDetailFID] [int] NOT NULL,
[OrderFID] [int] NOT NULL,
[Mover] [bit] NOT NULL CONSTRAINT [DF_ServiceDetailOrderMap_Mover] DEFAULT ((0)),
[Client] [bit] NOT NULL CONSTRAINT [DF_ServiceDetailOrderMap_Client] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ServiceDetailOrderMap] ADD CONSTRAINT [CK_ServiceDetailOrderMapFlagSetup] CHECK (([Mover]=(1) AND [Client]=(0) OR [Mover]=(0) AND [Client]=(1)))
GO
ALTER TABLE [dbo].[ServiceDetailOrderMap] ADD CONSTRAINT [PK_ServiceDetailOrderMap] PRIMARY KEY NONCLUSTERED ([ServiceDetailOrderMapID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ServiceDetailOrderMap] ADD CONSTRAINT [IX_ServiceDetailOrderMap_OrderService] UNIQUE NONCLUSTERED ([OrderFID], [ServiceDetailFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ServiceDetailOrderMap] ADD CONSTRAINT [FK_ServiceDetailOrderMap_Order] FOREIGN KEY ([OrderFID]) REFERENCES [dbo].[Orders] ([PriKey])
GO
ALTER TABLE [dbo].[ServiceDetailOrderMap] ADD CONSTRAINT [FK_ServiceDetailOrderMap_ServiceDetail] FOREIGN KEY ([ServiceDetailFID]) REFERENCES [dbo].[ServiceDetail] ([ServiceDetailID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[ServiceDetailOrderMap] TO [MssExec]
GRANT INSERT ON [dbo].[ServiceDetailOrderMap] TO [MssExec]
GRANT DELETE ON [dbo].[ServiceDetailOrderMap] TO [MssExec]
GRANT UPDATE ON [dbo].[ServiceDetailOrderMap] TO [MssExec]
GO