IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE NAME ='EST_NF_ENT_CHECKIN_ENTRADA_TEMP_CAB_DANFE_PROV')
BEGIN 
CREATE TABLE [dbo].[EST_NF_ENT_CHECKIN_ENTRADA_TEMP_CAB_DANFE_PROV](
	[CD_CTR_CAB] [bigint] NOT NULL,
	[CD_CTR_DANFE_PROV] [int] NOT NULL,
 CONSTRAINT [PK_EST_NF_ENT_CHECKIN_ENTRADA_TEMP_CAB_DANFE_PROV] PRIMARY KEY CLUSTERED 
(
	[CD_CTR_CAB] ASC,
	[CD_CTR_DANFE_PROV] 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_CHECKIN_ENTRADA_TEMP_CAB_DANFE_PROV]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_ENT_CHECKIN_ENTRADA_TEMP_CAB_DANFE_PROV_EST_NF_ENT_CHECKIN_ENTRADA_TEMP_CAB_DANFE_PROV] FOREIGN KEY([CD_CTR_CAB], [CD_CTR_DANFE_PROV])
REFERENCES [dbo].[EST_NF_ENT_CHECKIN_ENTRADA_TEMP_CAB_DANFE_PROV] ([CD_CTR_CAB], [CD_CTR_DANFE_PROV])

ALTER TABLE [dbo].[EST_NF_ENT_CHECKIN_ENTRADA_TEMP_CAB_DANFE_PROV] CHECK CONSTRAINT [FK_EST_NF_ENT_CHECKIN_ENTRADA_TEMP_CAB_DANFE_PROV_EST_NF_ENT_CHECKIN_ENTRADA_TEMP_CAB_DANFE_PROV]
END