/****** Object:  Table [dbo].[EST_NF_ENT_EST_NF_NFE_INU]    Script Date: 06/26/2013 15:36:19 ******/
IF  NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_NF_ENT_EST_NF_NFE_INU]') AND type in (N'U'))
begin
	CREATE TABLE [dbo].[EST_NF_ENT_EST_NF_NFE_INU](
		[CD_INU] [int] NOT NULL,
		[CD_EMP] [int] NOT NULL,
		[CD_FILIAL] [int] NOT NULL,
		[CD_NF] [int] NOT NULL,
	 CONSTRAINT [PK_EST_NF_ENT_EST_NF_NFE_INU] PRIMARY KEY CLUSTERED 
	(
		[CD_INU] ASC,
		[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_EST_NF_NFE_INU]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_ENT_EST_NF_NFE_INU_EST_NF_ENT] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_NF])
	REFERENCES [dbo].[EST_NF_ENT] ([CD_EMP], [CD_FILIAL], [CD_NF])

	ALTER TABLE [dbo].[EST_NF_ENT_EST_NF_NFE_INU] CHECK CONSTRAINT [FK_EST_NF_ENT_EST_NF_NFE_INU_EST_NF_ENT]

	ALTER TABLE [dbo].[EST_NF_ENT_EST_NF_NFE_INU]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_ENT_EST_NF_NFE_INU_EST_NF_NFE_INU] FOREIGN KEY([CD_INU])
	REFERENCES [dbo].[EST_NF_NFE_INU] ([CD_INU])

	ALTER TABLE [dbo].[EST_NF_ENT_EST_NF_NFE_INU] CHECK CONSTRAINT [FK_EST_NF_ENT_EST_NF_NFE_INU_EST_NF_NFE_INU]

	ALTER TABLE [dbo].[EST_NF_ENT_EST_NF_NFE_INU] ADD  CONSTRAINT [DF_EST_NF_ENT_EST_NF_NFE_INU_CD_INU]  DEFAULT ((0)) FOR [CD_INU]

	ALTER TABLE [dbo].[EST_NF_ENT_EST_NF_NFE_INU] ADD  CONSTRAINT [DF_EST_NF_ENT_EST_NF_NFE_INU_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]

	ALTER TABLE [dbo].[EST_NF_ENT_EST_NF_NFE_INU] ADD  CONSTRAINT [DF_EST_NF_ENT_EST_NF_NFE_INU_CD_FILIAL]  DEFAULT ((0)) FOR [CD_FILIAL]

	ALTER TABLE [dbo].[EST_NF_ENT_EST_NF_NFE_INU] ADD  CONSTRAINT [DF_EST_NF_ENT_EST_NF_NFE_INU_CD_NF]  DEFAULT ((0)) FOR [CD_NF]
end