
/*cat_atributo*/

if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='equ_detallePagoAlquiler' and column_name = 'id_itemDocumento' )
begin
alter table [equ_detallePagoAlquiler] add [id_itemDocumento] int  NOT NULL DEFAULT 0
end

/*relaciones*/

if not exists (select * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS where CONSTRAINT_NAME= 'FK_equ_detallePagoAlquiler_id_itemDocumento')
begin 
ALTER TABLE [equ_detallePagoAlquiler] ADD CONSTRAINT
	FK_equ_detallePagoAlquiler_id_itemDocumento FOREIGN KEY
	([id_itemDocumento]) REFERENCES [doc_itemDocumento]
	(id) ON UPDATE  NO ACTION ON DELETE  NO ACTION 
end


/*auxiliares*/
if  exists(select * FROM INFORMATION_SCHEMA.TABLES  where Table_Name='equ_detallePagoAlquiler_aux' )drop table equ_detallePagoAlquiler_aux
go
create table [equ_detallePagoAlquiler_aux] (
uid varchar (500)
,[detallePagoAlquiler] varchar (300)
,[detallePagoAlquiler_codigo] varchar (100)
,[detallePagoAlquiler_pagoAlquiler_pagoAlquiler] varchar (300)
,[detallePagoAlquiler_pagoAlquiler_pagoAlquiler_codigo] varchar (100)
,[detallePagoAlquiler_equipo_equipo] varchar (300)
,[detallePagoAlquiler_equipo_equipo_codigo] varchar (100)
,[detallePagoAlquiler_equipo_equipo_serial] varchar (100)
,[detallePagoAlquiler_documento_documento] varchar (300)
,[detallePagoAlquiler_documento_documento_codigo] varchar (100)
,[detallePagoAlquiler_documento_documento_numero] int
,[detallePagoAlquiler_itemDocumento_itemDocumento] varchar (300)
,[detallePagoAlquiler_itemDocumento_itemDocumento_codigo] varchar (100)

)