IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE NAME = 'EST_NF_ENT_DANFE_PROVISORIO_FILIAIS')
begin
CREATE TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_FILIAIS](
	[CD_CTR] [int] NOT NULL,
	[CD_FILIAL_ORIG] [int] NOT NULL,
	[FLAG_GRP_ECON] [int] NOT NULL,
 CONSTRAINT [PK_EST_NF_ENT_DANFE_PROVISORIO_FILIAIS] 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_NF_ENT_DANFE_PROVISORIO_FILIAIS] ADD  CONSTRAINT [DF_EST_NF_ENT_DANFE_PROVISORIO_FILIAIS_CD_CTR]  DEFAULT ((0)) FOR [CD_CTR]

ALTER TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_FILIAIS] ADD  CONSTRAINT [DF_Table_1_CD_FILIAL_3]  DEFAULT ((0)) FOR [CD_FILIAL_ORIG]

ALTER TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_FILIAIS] ADD  CONSTRAINT [DF_EST_NF_ENT_DANFE_PROVISORIO_FILIAIS_FLAG_GRP_ECON]  DEFAULT ((0)) FOR [FLAG_GRP_ECON]

ALTER TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_FILIAIS]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_ENT_DANFE_PROVISORIO_FILIAIS_EST_NF_ENT_DANFE_PROVISORIO] FOREIGN KEY([CD_CTR])
REFERENCES [dbo].[EST_NF_ENT_DANFE_PROVISORIO] ([CD_CTR])

ALTER TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_FILIAIS] CHECK CONSTRAINT [FK_EST_NF_ENT_DANFE_PROVISORIO_FILIAIS_EST_NF_ENT_DANFE_PROVISORIO]
end

