CREATE TABLE [dbo].[PDV_VD_EST_PED_VD_AGRUPAMENTO](
	[CD_EMP] [int] NOT NULL,
	[CD_FILIAL] [int] NOT NULL,
	[CD_PED] [int] NOT NULL,
	[CD_FILIAL_VD] [int] NOT NULL,
	[CD_VD] [int] NOT NULL,
 CONSTRAINT [PK_PDV_VD_EST_PED_VD_AGRUPAMENTO] PRIMARY KEY CLUSTERED 
(
	[CD_EMP] ASC,
	[CD_FILIAL] ASC,
	[CD_PED] ASC,
	[CD_FILIAL_VD] ASC,
	[CD_VD] 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].[PDV_VD_EST_PED_VD_AGRUPAMENTO]  WITH CHECK ADD  CONSTRAINT [FK_PDV_VD_EST_PED_VD_AGRUPAMENTO_EST_PED_VD] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_PED])
REFERENCES [dbo].[EST_PED_VD] ([CD_EMP], [CD_FILIAL], [CD_PED])
GO

ALTER TABLE [dbo].[PDV_VD_EST_PED_VD_AGRUPAMENTO] CHECK CONSTRAINT [FK_PDV_VD_EST_PED_VD_AGRUPAMENTO_EST_PED_VD]
GO

ALTER TABLE [dbo].[PDV_VD_EST_PED_VD_AGRUPAMENTO]  WITH CHECK ADD  CONSTRAINT [FK_PDV_VD_EST_PED_VD_AGRUPAMENTO_PDV_VD] FOREIGN KEY([CD_VD], [CD_FILIAL_VD], [CD_EMP])
REFERENCES [dbo].[PDV_VD] ([CD_VD], [CD_FILIAL], [CD_EMP])
GO

ALTER TABLE [dbo].[PDV_VD_EST_PED_VD_AGRUPAMENTO] CHECK CONSTRAINT [FK_PDV_VD_EST_PED_VD_AGRUPAMENTO_PDV_VD]
GO


