 

IF OBJECT_ID('EST_NF_ENT_CANCEL_SOLIC') IS NULL
	BEGIN 
		CREATE TABLE [dbo].[EST_NF_ENT_CANCEL_SOLIC](
			[CD_EMP] [int] NOT NULL,
			[CD_FILIAL] [int] NOT NULL,
			[CD_NF] [int] NOT NULL,
			[CD_USU] [int] NOT NULL,
			[CD_MT_CANCEL] [int] NOT NULL, 
			[ST_DENEGADA] [int] NOT NULL, 
			[DT_CANCEL] [datetime] NULL, 
			[DT_CAD] [datetime] NULL,
		 CONSTRAINT [PK_EST_NF_ENT_CANCEL_SOLIC] PRIMARY KEY CLUSTERED 
		(
			[CD_EMP] ASC,
			[CD_FILIAL] ASC,
			[CD_NF] 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_CANCEL_SOLIC]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_ENT_CANCEL_SOLIC_EST_NF_ENT] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_NF])
		REFERENCES [dbo].[EST_NF_ENT] ([CD_EMP], [CD_FILIAL], [CD_NF])
		ON UPDATE CASCADE
		ON DELETE CASCADE
		
		ALTER TABLE [dbo].[EST_NF_ENT_CANCEL_SOLIC] CHECK CONSTRAINT [FK_EST_NF_ENT_CANCEL_SOLIC_EST_NF_ENT]
		
		ALTER TABLE [dbo].[EST_NF_ENT_CANCEL_SOLIC]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_ENT_CANCEL_SOLIC_GLB_USU] FOREIGN KEY([CD_USU])
		REFERENCES [dbo].[GLB_USU] ([CD_USU])
		
		ALTER TABLE [dbo].[EST_NF_ENT_CANCEL_SOLIC] CHECK CONSTRAINT [FK_EST_NF_ENT_CANCEL_SOLIC_GLB_USU]
		
		
		
	END

	