
IF  NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_NF_SAI_PED_VD_PEND_RET_WMS]') AND type in (N'U'))
begin 
	  
	CREATE TABLE [dbo].[EST_NF_SAI_PED_VD_PEND_RET_WMS](
		[CD_EMP] [int] NOT NULL,
		[CD_FILIAL] [int] NOT NULL,
		[CD_PED] [int] NOT NULL,
		[CD_NF] [int] NOT NULL
	 CONSTRAINT [PK_EST_NF_SAI_PED_VD_PEND_RET_WMS] PRIMARY KEY CLUSTERED 
	(
		[CD_EMP] ASC,
		[CD_FILIAL] ASC,
		[CD_PED] ASC,
		[CD_NF] ASC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
	) ON [PRIMARY]



	ALTER TABLE [dbo].[EST_NF_SAI_PED_VD_PEND_RET_WMS]  WITH NOCHECK ADD  CONSTRAINT [FK_EST_NF_SAI_PED_VD_PEND_RET_WMS_EST_NF_SAI] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_NF])
	REFERENCES [dbo].[EST_NF_SAI] ([CD_EMP], [CD_FILIAL], [CD_NF])
	ON UPDATE CASCADE


	ALTER TABLE [dbo].[EST_NF_SAI_PED_VD_PEND_RET_WMS] CHECK CONSTRAINT [FK_EST_NF_SAI_PED_VD_PEND_RET_WMS_EST_NF_SAI]
	

	ALTER TABLE [dbo].[EST_NF_SAI_PED_VD_PEND_RET_WMS]  WITH NOCHECK ADD  CONSTRAINT [FK_EST_NF_SAI_PED_VD_PEND_RET_WMS_EST_PED_VD] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_PED])
	REFERENCES [dbo].[EST_PED_VD] ([CD_EMP], [CD_FILIAL], [CD_PED])
	ON UPDATE CASCADE
	

	ALTER TABLE [dbo].[EST_NF_SAI_PED_VD_PEND_RET_WMS] CHECK CONSTRAINT [FK_EST_NF_SAI_PED_VD_PEND_RET_WMS_EST_PED_VD]
	

end



