
/****** Object:  Table [dbo].[EST_PRECIFICACAO_GRP_PRECO_PAPEL]    Script Date: 03/12/2014 14:59:09 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_PRECIFICACAO_GRP_PRECO_PAPEL]') AND type in (N'U'))
	begin
		return;
	end
else

BEGIN
  
	SET ANSI_NULLS ON  
	SET QUOTED_IDENTIFIER ON  
	CREATE TABLE [dbo].[EST_PRECIFICACAO_GRP_PRECO_PAPEL](
		[CD_EMP] [int] NOT NULL,
		[CD_GRUPO] [int] NOT NULL,
		[CD_ARV_MERC_PAPEL] [int] NOT NULL CONSTRAINT [DF_EST_PRECIFICACAO_GRP_PRECO_PAPEL_NAO_DEFINIDO]  DEFAULT ((0)),
		[PERC_MARGEM] [money] NULL CONSTRAINT [DF_EST_PRECIFICACAO_GRP_PRECO_PAPEL_FORMADOR_IMAGEM]  DEFAULT ((0)),
	 CONSTRAINT [PK_EST_PRECIFICACAO_GRP_PRECO_PAPEL_1] PRIMARY KEY CLUSTERED 
	(
		[CD_EMP] ASC,
		[CD_GRUPO] ASC,
		[CD_ARV_MERC_PAPEL] 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_PRECIFICACAO_GRP_PRECO_PAPEL]  WITH CHECK ADD  CONSTRAINT [FK_EST_PRECIFICACAO_GRP_PRECO_PAPEL_EST_ARV_MERC_PAPEL] FOREIGN KEY([CD_EMP], [CD_ARV_MERC_PAPEL])
	REFERENCES [dbo].[EST_ARV_MERC_PAPEL] ([CD_EMP], [CD_ARV_MERC_PAPEL])
	 
	ALTER TABLE [dbo].[EST_PRECIFICACAO_GRP_PRECO_PAPEL] CHECK CONSTRAINT [FK_EST_PRECIFICACAO_GRP_PRECO_PAPEL_EST_ARV_MERC_PAPEL]
	 

	ALTER TABLE [dbo].[EST_PRECIFICACAO_GRP_PRECO_PAPEL]  WITH CHECK ADD  CONSTRAINT [FK_EST_PRECIFICACAO_GRP_PRECO_PAPEL_EST_PRECIFICACAO_GRP_PRECO] FOREIGN KEY([CD_EMP], [CD_GRUPO])
	REFERENCES [dbo].[EST_PRECIFICACAO_GRP_PRECO] ([CD_EMP], [CD_GRUPO])
	ON DELETE CASCADE
	 
	ALTER TABLE [dbo].[EST_PRECIFICACAO_GRP_PRECO_PAPEL] CHECK CONSTRAINT [FK_EST_PRECIFICACAO_GRP_PRECO_PAPEL_EST_PRECIFICACAO_GRP_PRECO] 

END