IF OBJECT_ID('EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE') IS NULL 
begin
CREATE TABLE [dbo].[EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE](
	[CD_CTR] [int] NOT NULL,
	[DT_CAD] [datetime] NOT NULL,
 CONSTRAINT [PK_EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE] 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_SAI_LOTE_ENVIO_WMS_PENDENTE] ADD  CONSTRAINT [DF_EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE_CD_CTR]  DEFAULT ((0)) FOR [CD_CTR]

ALTER TABLE [dbo].[EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE] ADD  CONSTRAINT [DF_EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE_DT_CAD]  DEFAULT (getdate()) FOR [DT_CAD]

ALTER TABLE [dbo].[EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE_EST_NF_SAI_LOTE_ENVIO_WMS] FOREIGN KEY([CD_CTR])
REFERENCES [dbo].[EST_NF_SAI_LOTE_ENVIO_WMS] ([CD_CTR])
ON UPDATE CASCADE
ON DELETE CASCADE

ALTER TABLE [dbo].[EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE] CHECK CONSTRAINT [FK_EST_NF_SAI_LOTE_ENVIO_WMS_PENDENTE_EST_NF_SAI_LOTE_ENVIO_WMS]
end
