if not exists (select * FROM INFORMATION_SCHEMA.COLUMNS where Table_Name='alq_historicoAlquiler'  and column_name = 'fechaEstado' )
begin  
alter table [alq_historicoAlquiler] add [fechaEstado] smalldatetime NOT NULL DEFAULT getdate()
end
go
if not exists (select * FROM INFORMATION_SCHEMA.COLUMNS where Table_Name='alq_historicoAlquiler'  and column_name = 'id_equipo' )
begin  
alter table [alq_historicoAlquiler] add [id_equipo] int NULL DEFAULT 0  FOREIGN KEY (id_equipo) REFERENCES equ_equipo(id)
end
go
if not exists (select * FROM INFORMATION_SCHEMA.COLUMNS where Table_Name='alq_historicoAlquiler'  and column_name = 'id_estadoEquipo' )
begin  
alter table [alq_historicoAlquiler] add [id_estadoEquipo] int NULL DEFAULT 0  FOREIGN KEY (id_estadoEquipo) REFERENCES equ_estadoEquipo(id)
end
go

if not exists (select * FROM INFORMATION_SCHEMA.COLUMNS where Table_Name='alq_historicoAlquiler'  and column_name = 'id_documento' )
begin  
alter table [alq_historicoAlquiler] add [id_documento] int NULL DEFAULT 0  FOREIGN KEY (id_documento) REFERENCES doc_documento(id)
end
go
