IF NOT EXISTS (SELECT * FROM sysobjects WHERE Name='Clientes_Invitados_Mov' AND xtype='U')
BEGIN
	CREATE TABLE dbo.Clientes_Invitados_Mov
	(
	Id_Invitacion			INT IDENTITY(1,1) NOT NULL,
	Id_Cliente				INT NOT NULL,
	Id_Cliente_D			INT NOT NULL,
	Fecha_Mov				DATETIME DEFAULT(GETDATE()) NOT NULL,
	Fecha					DATETIME NOT NULL
	)
END
GO

IF NOT EXISTS (SELECT * FROM sysobjects WHERE Name='PK_CliIM_PorId' AND xtype='PK')
BEGIN
	ALTER TABLE Clientes_Invitados_Mov ADD CONSTRAINT PK_CliIM_PorId PRIMARY KEY CLUSTERED (Id_Invitacion)	
END
GO

IF NOT EXISTS (SELECT * FROM sysobjects WHERE Name='FK_CliIM_Clientes' AND xtype='F')
BEGIN
	ALTER TABLE Clientes_Invitados_Mov ADD CONSTRAINT FK_CliIM_Clientes FOREIGN KEY (Id_Cliente) REFERENCES Clientes (Id_Cliente)
END
GO

IF NOT EXISTS (SELECT * FROM sysobjects WHERE Name='FK_CliIM_Clientes_D' AND xtype='F')
BEGIN
	ALTER TABLE Clientes_Invitados_Mov ADD CONSTRAINT FK_CliIM_Clientes_D FOREIGN KEY (Id_Cliente_D) REFERENCES Clientes (Id_Cliente)
END
GO

