IF OBJECT_ID('EST_NF_ENT_IT_PBM_GLOSADA') IS NULL
begin
CREATE TABLE [dbo].[EST_NF_ENT_IT_PBM_GLOSADA](
	[CD_EMP] [int] NOT NULL,
	[CD_FILIAL] [int] NOT NULL,
	[CD_NF] [int] NOT NULL,
	[CD_PROD] [int] NOT NULL,
	[CD_USU] [int] NOT NULL,
	[DT_CAD] [datetime] NULL,
 CONSTRAINT [PK_EST_NF_ENT_IT_PBM_GLOSADA] PRIMARY KEY CLUSTERED 
(
	[CD_EMP] ASC,
	[CD_FILIAL] ASC,
	[CD_NF] ASC,
	[CD_PROD] 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_IT_PBM_GLOSADA] ADD  CONSTRAINT [DF_EST_NF_ENT_IT_PBM_GLOSADA_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]

ALTER TABLE [dbo].[EST_NF_ENT_IT_PBM_GLOSADA] ADD  CONSTRAINT [DF_EST_NF_ENT_IT_PBM_GLOSADA_CD_FILIAL]  DEFAULT ((0)) FOR [CD_FILIAL]

ALTER TABLE [dbo].[EST_NF_ENT_IT_PBM_GLOSADA] ADD  CONSTRAINT [DF_EST_NF_ENT_IT_PBM_GLOSADA_CD_NF]  DEFAULT ((0)) FOR [CD_NF]

ALTER TABLE [dbo].[EST_NF_ENT_IT_PBM_GLOSADA] ADD  CONSTRAINT [DF_EST_NF_ENT_IT_PBM_GLOSADA_CD_PROD]  DEFAULT ((0)) FOR [CD_PROD]

ALTER TABLE [dbo].[EST_NF_ENT_IT_PBM_GLOSADA] ADD  CONSTRAINT [DF_EST_NF_ENT_IT_PBM_GLOSADA_CD_USU]  DEFAULT ((0)) FOR [CD_USU]

ALTER TABLE [dbo].[EST_NF_ENT_IT_PBM_GLOSADA]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_ENT_IT_PBM_GLOSADA_EST_NF_ENT_IT] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_NF], [CD_PROD])
REFERENCES [dbo].[EST_NF_ENT_IT] ([CD_EMP], [CD_FILIAL], [CD_NF], [CD_PROD])

ALTER TABLE [dbo].[EST_NF_ENT_IT_PBM_GLOSADA] CHECK CONSTRAINT [FK_EST_NF_ENT_IT_PBM_GLOSADA_EST_NF_ENT_IT]
end