CREATE TABLE [dbo].[BC_QT_QD_QI_CPL](
	[CD_EMP] [int] NOT NULL,
	[CD_QTDI] [int] NOT NULL,
	[CD_QTDI_IT] [int] NOT NULL,
	[TP] [int] NULL,
	[NIVEL] [nvarchar](10) NULL,
	[DS_GRP] [nvarchar](50) NULL,
	[VLR_GRP] [money] NULL,
 CONSTRAINT [PK_BC_QT_QD_QI_CPL] PRIMARY KEY CLUSTERED 
(
	[CD_EMP] ASC,
	[CD_QTDI] ASC,
	[CD_QTDI_IT] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[BC_QT_QD_QI_CPL]  WITH CHECK ADD  CONSTRAINT [FK_BC_QT_QD_QI_CPL_BC_QT_QD_QI] FOREIGN KEY([CD_EMP], [CD_QTDI])
REFERENCES [dbo].[BC_QT_QD_QI] ([CD_EMP], [CD_QTDI])
ON UPDATE CASCADE
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[BC_QT_QD_QI_CPL] CHECK CONSTRAINT [FK_BC_QT_QD_QI_CPL_BC_QT_QD_QI]
GO

ALTER TABLE [dbo].[BC_QT_QD_QI_CPL] ADD  CONSTRAINT [DF_BC_QT_QD_QI_CPL_TP]  DEFAULT ((0)) FOR [TP]
GO

ALTER TABLE [dbo].[BC_QT_QD_QI_CPL] ADD  CONSTRAINT [DF_BC_QT_QD_QI_CPL_VLR_GRP]  DEFAULT ((0)) FOR [VLR_GRP]
GO


