IF  NOT EXISTS (SELECT * FROM sys.objects 
					WHERE object_id = OBJECT_ID(N'[dbo].[PDV_VD_FISCAL_CONFIRMACAO]') 
					AND type in (N'U')) 
begin
CREATE TABLE [dbo].[PDV_VD_FISCAL_CONFIRMACAO](
	[CD_EMP] [int] NOT NULL,
	[CD_FILIAL] [int] NOT NULL,
	[CD_VD] [int] NOT NULL,
	[DT_CAD] [datetime] NULL,
	[CD_CTR] [int] NOT NULL,
	[DT_CAD_CONFIRMACAO] [datetime] NOT NULL,
 CONSTRAINT [PK_PDV_VD_FISCAL_CONFIRMACAO] 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].[PDV_VD_FISCAL_CONFIRMACAO] ADD  CONSTRAINT [DF_PDV_VD_FISCAL_CONFIRMACAO_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]

ALTER TABLE [dbo].[PDV_VD_FISCAL_CONFIRMACAO] ADD  CONSTRAINT [DF_PDV_VD_FISCAL_CONFIRMACAO_CD_FILIAL]  DEFAULT ((0)) FOR [CD_FILIAL]

ALTER TABLE [dbo].[PDV_VD_FISCAL_CONFIRMACAO] ADD  CONSTRAINT [DF_PDV_VD_FISCAL_CONFIRMACAO_CD_VD]  DEFAULT ((0)) FOR [CD_VD]

ALTER TABLE [dbo].[PDV_VD_FISCAL_CONFIRMACAO] ADD  CONSTRAINT [DF_PDV_VD_FISCAL_CONFIRMACAO_CD_CTR]  DEFAULT ((0)) FOR [CD_CTR]

ALTER TABLE [dbo].[PDV_VD_FISCAL_CONFIRMACAO] ADD  CONSTRAINT [DF_PDV_VD_FISCAL_CONFIRMACAO_DT_CAD_CONFIRMACAO]  DEFAULT (getdate()) FOR [DT_CAD_CONFIRMACAO]

ALTER TABLE [dbo].[PDV_VD_FISCAL_CONFIRMACAO]  WITH CHECK ADD  CONSTRAINT [FK_PDV_VD_FISCAL_CONFIRMACAO_PDV_VD] FOREIGN KEY([CD_VD], [CD_FILIAL], [CD_EMP])
REFERENCES [dbo].[PDV_VD] ([CD_VD], [CD_FILIAL], [CD_EMP])

ALTER TABLE [dbo].[PDV_VD_FISCAL_CONFIRMACAO] CHECK CONSTRAINT [FK_PDV_VD_FISCAL_CONFIRMACAO_PDV_VD]
end

