IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_PROD_PRECO_COND_COMPRA_CPL]') AND type in (N'U'))
DROP TABLE [dbo].[EST_PROD_PRECO_COND_COMPRA_CPL]
GO   

/****** Object:  Table [dbo].[EST_PROD_PRECO_COND_COMPRA_CPL]    Script Date: 08/08/2012 15:47:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO 

CREATE TABLE [dbo].[EST_PROD_PRECO_COND_COMPRA_CPL](
	[CD_EMP] [int] NOT NULL,
	[CD_COND_COMPRA] [int] NOT NULL,
	[CD_PROD] [int] NOT NULL,
	[VLR_PROD] [money] NOT NULL,
	[PERC_DESC] [money] NOT NULL,
 CONSTRAINT [PK_EST_PROD_PRECO_COND_COMPRA_CPL] PRIMARY KEY CLUSTERED 
(
	[CD_EMP],
	[CD_COND_COMPRA],
	[CD_PROD] )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[EST_PROD_PRECO_COND_COMPRA_CPL]  WITH CHECK ADD  
			CONSTRAINT [FK_EST_PROD_PRECO_COND_COMPRA_CPL_EST_PROD_PRECO_COND_COMPRA] FOREIGN KEY(  [CD_EMP],[CD_COND_COMPRA])
REFERENCES [dbo].[EST_PROD_PRECO_COND_COMPRA] ( [CD_EMP],[CD_COND_COMPRA] )
GO
ALTER TABLE [dbo].[EST_PROD_PRECO_COND_COMPRA_CPL] CHECK CONSTRAINT [FK_EST_PROD_PRECO_COND_COMPRA_CPL_EST_PROD_PRECO_COND_COMPRA]
GO
 
SET ANSI_PADDING OFF
GO 
ALTER TABLE [dbo].[EST_PROD_PRECO_COND_COMPRA_CPL] ADD  CONSTRAINT [DF_EST_PROD_PRECO_COND_COMPRA_CPL_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]
GO 
ALTER TABLE [dbo].[EST_PROD_PRECO_COND_COMPRA_CPL] ADD  CONSTRAINT [DF_EST_PROD_PRECO_COND_COMPRA_CPL_CD_COND_COMPRA]  DEFAULT ((0)) FOR [CD_COND_COMPRA]
GO 
ALTER TABLE [dbo].[EST_PROD_PRECO_COND_COMPRA_CPL] ADD  CONSTRAINT [DF_EST_PROD_PRECO_COND_COMPRA_CPL_CD_PROD]  DEFAULT ((0)) FOR [CD_PROD]
GO
ALTER TABLE [dbo].[EST_PROD_PRECO_COND_COMPRA_CPL] ADD  CONSTRAINT [DF_EST_PROD_PRECO_COND_COMPRA_CPL_VLR_PROD]  DEFAULT ((0)) FOR [VLR_PROD]
GO
ALTER TABLE [dbo].[EST_PROD_PRECO_COND_COMPRA_CPL] ADD  CONSTRAINT [DF_EST_PROD_PRECO_COND_COMPRA_CPL_PERC_DESC]  DEFAULT ((0)) FOR [PERC_DESC]
GO


