

if not exists(select * from sys.all_columns where name='esMaestro')
begin 
alter table _tablas add esMaestro bit default 0 
end
go
insert into _tablas(tabla,esMultiempresa ,duplicar ,eliminarIntermedias,esMaestro)
SELECT name ,1 ,0,0,0 FROM sys.objects WHERE type in (N'U')
and  not exists (select  tabla  from _tablas where tabla=name COLLATE SQL_Latin1_General_CP1_CI_AS )
and not  name like'%_aux%'
and  name not in ('_idae','_errores','_columnas','_tablas')

update _tablas set esMaestro=0

update _tablas set esMaestro=1 where tabla in ('doc_tipoPendiente','gen_tipoArchivo')




