IF NOT EXISTS (SELECT * FROM sysobjects WHERE Name='Proveedores_XCampos' AND xtype='U')
BEGIN
	CREATE TABLE dbo.Proveedores_XCampos
	(
	Id_Proveedor			INT NOT NULL,
	Id_Campo				INT NOT NULL,
	Valor_String			VARCHAR(101),
	Valor_Integer			INT,
	Valor_DT				DATETIME,
	Valor_Decimal			DECIMAL(20,4),
	Valor_Memo				TEXT
	)
END
GO

IF EXISTS (SELECT * FROM sysobjects WHERE Name='Proveedores_XCampos' AND xtype='U')
BEGIN
	ALTER TABLE Proveedores_XCampos ADD CONSTRAINT PK_ProXC_PorId PRIMARY KEY CLUSTERED (Id_Proveedor, Id_Campo)	
END
GO

IF EXISTS (SELECT * FROM sysobjects WHERE Name='Proveedores_XCampos' AND xtype='U')
BEGIN
	ALTER TABLE Proveedores_XCampos ADD CONSTRAINT FK_ProXC_Proveedores FOREIGN KEY (Id_Proveedor) REFERENCES Proveedores (Id_Proveedor)
END

IF EXISTS (SELECT * FROM sysobjects WHERE Name='Proveedores_XCampos' AND xtype='U')
BEGIN
	ALTER TABLE Proveedores_XCampos ADD CONSTRAINT FK_ProXC_XCampos FOREIGN KEY (Id_Campo) REFERENCES xCampos (Id_Campo)
END





