 IF NOT EXISTS (SELECT 1 FROM SYS.TABLES WHERE NAME ='PG_CRED_EST_NF_SAI_DAR') 
 begin
    CREATE TABLE [dbo].PG_CRED_EST_NF_SAI_DAR(
	    [CD_EMP] [int] NOT NULL,
	    [CD_FILIAL] [int] NOT NULL,
	    [CD_NF] [int] NOT NULL,
	    [NR_DP] [int] NOT NULL,
	    [ANO] [int] NOT NULL,
	    [CD_DAR] [int] NOT NULL,
	CONSTRAINT [PK_PG_CRED_EST_NF_SAI_DAR] PRIMARY KEY CLUSTERED 
    (
	    [CD_EMP] ASC,
	    [CD_FILIAL] ASC,
	    [CD_NF] ASC,
	    [NR_DP] ASC,
	    [ANO] ASC,
	    [CD_DAR] 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].[PG_CRED_EST_NF_SAI_DAR] ADD  CONSTRAINT [DF_PG_CRED_EST_NF_SAI_DAR_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]
    ALTER TABLE [dbo].[PG_CRED_EST_NF_SAI_DAR] ADD  CONSTRAINT [DF_PG_CRED_EST_NF_SAI_DAR_CD_FILIAL]  DEFAULT ((0)) FOR [CD_FILIAL]
    ALTER TABLE [dbo].[PG_CRED_EST_NF_SAI_DAR] ADD  CONSTRAINT [DF_PG_CRED_EST_NF_SAI_DAR_CD_NF]  DEFAULT ((0)) FOR [CD_NF]
    ALTER TABLE [dbo].[PG_CRED_EST_NF_SAI_DAR] ADD  CONSTRAINT [DF_PG_CRED_EST_NF_SAI_DAR_NR_DP]  DEFAULT ((0)) FOR [NR_DP]
    ALTER TABLE [dbo].[PG_CRED_EST_NF_SAI_DAR] ADD  CONSTRAINT [DF_PG_CRED_EST_NF_SAI_DAR_ANO]  DEFAULT ((0)) FOR [ANO]
    ALTER TABLE [dbo].[PG_CRED_EST_NF_SAI_DAR] ADD  CONSTRAINT [DF_PG_CRED_EST_NF_SAI_DAR_CD_DAR]  DEFAULT ((0)) FOR [CD_DAR]
    ALTER TABLE [dbo].[PG_CRED_EST_NF_SAI_DAR]  WITH CHECK ADD  CONSTRAINT [FK_PG_CRED_EST_NF_SAI_DAR_EST_NF_SAI] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_NF])
    REFERENCES [dbo].[EST_NF_SAI] ([CD_EMP], [CD_FILIAL], [CD_NF])
    ALTER TABLE [dbo].[PG_CRED_EST_NF_SAI_DAR] CHECK CONSTRAINT [FK_PG_CRED_EST_NF_SAI_DAR_EST_NF_SAI]
    ALTER TABLE [dbo].[PG_CRED_EST_NF_SAI_DAR]  WITH CHECK ADD  CONSTRAINT [FK_PG_CRED_EST_NF_SAI_DAR_PG_CRED_DUP_NR_CTR] FOREIGN KEY([CD_EMP], [CD_FILIAL], [NR_DP], [ANO])
    REFERENCES [dbo].[PG_CRED_DUP_NR_CTR] ([CD_EMP], [CD_FILIAL], [NR_DP], [ANO])
    ALTER TABLE [dbo].[PG_CRED_EST_NF_SAI_DAR] CHECK CONSTRAINT [FK_PG_CRED_EST_NF_SAI_DAR_PG_CRED_DUP_NR_CTR]
end

