

if not exists(select * FROM INFORMATION_SCHEMA.TABLES  where Table_Name='seg_cargo_actividad')
EXEC _ini_creartabla 'seg_cargo_actividad', 1
GO


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

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

IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[seg_cargo_actividad]') AND object_id = OBJECT_ID(N'[dbo].[FK_seg_cargo_actividad_id_cargo]')  )
ALTER TABLE [seg_cargo_actividad] ADD CONSTRAINT
	FK_seg_cargo_actividad_id_cargo FOREIGN KEY
	([id_cargo]) REFERENCES [seg_cargo]
	(id) 
ALTER TABLE [dbo].[seg_cargo_actividad] CHECK CONSTRAINT [FK_seg_cargo_actividad_id_cargo]
GO


IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[seg_cargo_actividad]') AND object_id = OBJECT_ID(N'[dbo].[FK_seg_cargo_actividad_id_catalogo_actividad]')  )
ALTER TABLE [seg_cargo_actividad] ADD CONSTRAINT
	FK_seg_cargo_actividad_id_catalogo_actividad FOREIGN KEY
	([id_catalogo.actividad]) REFERENCES [cat_catalogo.actividad]
	(id) 
ALTER TABLE [dbo].[seg_cargo_actividad] CHECK CONSTRAINT [FK_seg_cargo_actividad_id_catalogo_actividad]