


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


ALTER TABLE [doc_documento.ordenCompra]  WITH CHECK ADD  CONSTRAINT [FK_doc_documento_ordenCompra_id_sucursal] 
FOREIGN KEY([id_sucursal]) REFERENCES [ter_sucursal] ([id])

ALTER TABLE [doc_documento.ordenCompra] CHECK CONSTRAINT [FK_doc_documento_ordenCompra_id_sucursal]

end
