IF NOT EXISTS (SELECT * FROM SYS.COLUMNS WHERE NAME = 'CD_ARV_MERC_GENERO' AND OBJECT_ID = OBJECT_ID('EST_PROD_EST_ARV_MERCADOLOGICA'))
	ALTER TABLE EST_PROD_EST_ARV_MERCADOLOGICA ADD CD_ARV_MERC_GENERO INT NULL
ALTER TABLE [dbo].[EST_PROD_EST_ARV_MERCADOLOGICA] ADD  CONSTRAINT [DF_EST_PROD_EST_ARV_MERCADOLOGICA_CD_ARV_MERC_GENERO]  DEFAULT ((0)) FOR [CD_ARV_MERC_GENERO]
GO

ALTER TABLE [dbo].[EST_PROD_EST_ARV_MERCADOLOGICA]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_EST_ARV_MERCADOLOGICA_EST_ARV_MERC_GENERO] FOREIGN KEY([CD_EMP], [CD_ARV_MERC_GENERO])
REFERENCES [dbo].[EST_ARV_MERC_GENERO] ([CD_EMP], [CD_ARV_MERC_GENERO])
ON UPDATE CASCADE
GO

ALTER TABLE [dbo].[EST_PROD_EST_ARV_MERCADOLOGICA] CHECK CONSTRAINT [FK_EST_PROD_EST_ARV_MERCADOLOGICA_EST_ARV_MERC_GENERO]
GO	
