IF OBJECT_ID('PDV_VD_IT_VD_PBM_FINANCEIRO') IS NULL
begin
CREATE TABLE [dbo].[PDV_VD_IT_VD_PBM_FINANCEIRO](
	[CD_EMP] [int] NOT NULL,
	[CD_FILIAL] [int] NOT NULL,
	[CD_VD] [int] NOT NULL,
	[CD_IT] [int] NOT NULL,
	[NR_AUTORIZACAO] [varchar](20) NOT NULL,
	[VLR_PREVISTO] [money] NOT NULL,
 CONSTRAINT [PK_PDV_VD_IT_VD_PBM_FINANCEIRO] PRIMARY KEY CLUSTERED 
(
	[CD_EMP] ASC,
	[CD_FILIAL] ASC,
	[CD_VD] ASC,
	[CD_IT] ASC,
	[NR_AUTORIZACAO] 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].[PDV_VD_IT_VD_PBM_FINANCEIRO] ADD  CONSTRAINT [DF_PDV_VD_IT_VD_PBM_FINANCEIRO_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]

ALTER TABLE [dbo].[PDV_VD_IT_VD_PBM_FINANCEIRO] ADD  CONSTRAINT [DF_PDV_VD_IT_VD_PBM_FINANCEIRO_CD_FILIAL]  DEFAULT ((0)) FOR [CD_FILIAL]

ALTER TABLE [dbo].[PDV_VD_IT_VD_PBM_FINANCEIRO] ADD  CONSTRAINT [DF_PDV_VD_IT_VD_PBM_FINANCEIRO_CD_VD]  DEFAULT ((0)) FOR [CD_VD]

ALTER TABLE [dbo].[PDV_VD_IT_VD_PBM_FINANCEIRO] ADD  CONSTRAINT [DF_PDV_VD_IT_VD_PBM_FINANCEIRO_CD_IT]  DEFAULT ((0)) FOR [CD_IT]

ALTER TABLE [dbo].[PDV_VD_IT_VD_PBM_FINANCEIRO] ADD  CONSTRAINT [DF_PDV_VD_IT_VD_PBM_FINANCEIRO_NR_AUTORIZACAO]  DEFAULT ('') FOR [NR_AUTORIZACAO]

ALTER TABLE [dbo].[PDV_VD_IT_VD_PBM_FINANCEIRO] ADD  CONSTRAINT [DF_PDV_VD_IT_VD_PBM_FINANCEIRO_VLR_AGENDADO]  DEFAULT ((0)) FOR [VLR_PREVISTO]

ALTER TABLE [dbo].[PDV_VD_IT_VD_PBM_FINANCEIRO]  WITH CHECK ADD  CONSTRAINT [FK_PDV_VD_IT_VD_PBM_FINANCEIRO_PDV_VD_IT_VD_PBM] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_VD], [CD_IT], [NR_AUTORIZACAO])
REFERENCES [dbo].[PDV_VD_IT_VD_PBM] ([CD_EMP], [CD_FILIAL], [CD_VD], [CD_IT], [NR_AUTORIZACAO])

ALTER TABLE [dbo].[PDV_VD_IT_VD_PBM_FINANCEIRO] CHECK CONSTRAINT [FK_PDV_VD_IT_VD_PBM_FINANCEIRO_PDV_VD_IT_VD_PBM]
end