
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EST_NF_NFE_INU_EST_NF_NFE_INU_PEND]') AND parent_object_id = OBJECT_ID(N'[dbo].[EST_NF_NFE_INU]'))
ALTER TABLE [dbo].[EST_NF_NFE_INU] DROP CONSTRAINT [FK_EST_NF_NFE_INU_EST_NF_NFE_INU_PEND]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EST_NF_NFE_INU_EST_NFE_ENT_INU]') AND parent_object_id = OBJECT_ID(N'[dbo].[EST_NF_NFE_INU]'))
ALTER TABLE [dbo].[EST_NF_NFE_INU] DROP CONSTRAINT [FK_EST_NF_NFE_INU_EST_NFE_ENT_INU]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EST_NF_NFE_INU_EST_NFE_SAI_INU]') AND parent_object_id = OBJECT_ID(N'[dbo].[EST_NF_NFE_INU]'))
ALTER TABLE [dbo].[EST_NF_NFE_INU] DROP CONSTRAINT [FK_EST_NF_NFE_INU_EST_NFE_SAI_INU]
GO


/****** Object:  Table [dbo].[EST_NF_NFE_INU]    Script Date: 08/18/2012 14:45:13 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_NF_NFE_INU]') AND type in (N'U'))
DROP TABLE [dbo].[EST_NF_NFE_INU]
GO


/****** Object:  Table [dbo].[EST_NF_NFE_INU]    Script Date: 08/18/2012 14:45:13 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[EST_NF_NFE_INU](
	[CD_INU] [int] IDENTITY(1,1) NOT NULL,
	[CD_EMP] [int] NULL,
	[CD_FILIAL] [int] NULL,
	[ANO] [int] NULL,
	[CD_MODELO] [int] NULL,
	[CD_NF_SERIE] [int] NULL,
	[CD_MOTIVO] [int] NULL,
	[NR_NF] [int] NULL,
	[DT_CAD] [datetime] NULL,
 CONSTRAINT [PK_EST_NF_NFE_INUTILIZACAO] PRIMARY KEY CLUSTERED 
(
	[CD_INU] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[EST_NF_NFE_INU]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_NFE_INU_EST_NF_NFE_INU_PEND] FOREIGN KEY([CD_INU])
REFERENCES [dbo].[EST_NF_NFE_INU_PEND] ([CD_INU])
GO

ALTER TABLE [dbo].[EST_NF_NFE_INU] CHECK CONSTRAINT [FK_EST_NF_NFE_INU_EST_NF_NFE_INU_PEND]
GO

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

ALTER TABLE [dbo].[EST_NF_NFE_INU] CHECK CONSTRAINT [FK_EST_NF_NFE_INU_EST_NFE_ENT_INU]
GO

ALTER TABLE [dbo].[EST_NF_NFE_INU]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_NFE_INU_EST_NFE_SAI_INU] FOREIGN KEY([CD_INU])
REFERENCES [dbo].[EST_NF_SAI_EST_NF_NFE_INU] ([CD_INU])
GO

ALTER TABLE [dbo].[EST_NF_NFE_INU] CHECK CONSTRAINT [FK_EST_NF_NFE_INU_EST_NFE_SAI_INU]
GO


