IF NOT EXISTS (SELECT * FROM SYS.OBJECTS where OBJECT_NAME(OBJECT_ID)= 'EST_PED_VD_PAG')
BEGIN 

CREATE TABLE [DBO].[EST_PED_VD_PAG](
	[CD_CTR] [INT] IDENTITY(1,1) NOT NULL,
	[CD_EMP] [INT] NULL,
	[CD_FILIAL] [INT] NULL,
	[CD_PED] [INT] NULL,
	[CD_ORC_PAG] [INT] NULL,
	[CD_TIPO_PAG] [INT] NULL,
	[VLR_PAG] [REAL] NULL,
	[VLR_TROCO] [REAL] NULL,
	[CD_TIPO_MOEDA] [INT] NULL,
 CONSTRAINT [PK_EST_PED_VD_PAG] PRIMARY KEY CLUSTERED 
(
	[CD_CTR] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
 

ALTER TABLE [DBO].[EST_PED_VD_PAG]  WITH CHECK ADD  CONSTRAINT [FK_EST_PED_VD_PAG_EST_PED_VD] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_PED]) REFERENCES [DBO].[EST_PED_VD] ([CD_EMP], [CD_FILIAL], [CD_PED])
ALTER TABLE [DBO].[EST_PED_VD_PAG] CHECK CONSTRAINT [FK_EST_PED_VD_PAG_EST_PED_VD]
ALTER TABLE [DBO].[EST_PED_VD_PAG]  WITH CHECK ADD  CONSTRAINT [FK_EST_PED_VD_PAG_TELE_ORC_PAG] FOREIGN KEY([CD_ORC_PAG]) REFERENCES [DBO].[TELE_ORC_PAG] ([CD_ORC_PAG])
ALTER TABLE [DBO].[EST_PED_VD_PAG] CHECK CONSTRAINT [FK_EST_PED_VD_PAG_TELE_ORC_PAG]

END ;