 
 
 IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[gen_bodega]') AND object_id = OBJECT_ID(N'[dbo].[FK_gen_bodega_id_sucursal]')  )
begin
    ALTER TABLE [gen_bodega] ADD CONSTRAINT
	FK_gen_bodega_id_sucursal FOREIGN KEY
	([id_sucursal]) REFERENCES [ter_sucursal]
	(id) ON UPDATE  NO ACTION ON DELETE  NO ACTION 
end