if not exists(select * FROM [_columnas]  where [tabla]='tax_nivelTax')
begin
INSERT INTO [_columnas]
           ([tabla]
           ,[columna]
,[mostrarEnGrilla]
,[ordenGrilla]
           ,requerido,tipo,defecto,tamano)
select table_name, column_name,1,1, (case is_nullable when 'YES' then 0 else 1 end) as requerido,
data_type as tipo, column_default as defecto, character_maximum_length as tamano
from INFORMATION_SCHEMA.COLUMNS
where table_name='tax_nivelTax' AND table_name not like 'view%' and table_name not like '[_]%' and table_name not like '%_aux'
order by table_name

INSERT INTO [_columnas]
           ([tabla]
           ,[columna]
,[mostrarEnGrilla]
,[ordenGrilla]
           ,requerido,tipo,defecto,tamano)
select table_name, column_name,1,1, (case is_nullable when 'YES' then 0 else 1 end) as requerido,
data_type as tipo, column_default as defecto, character_maximum_length as tamano
from INFORMATION_SCHEMA.COLUMNS
where table_name='tax_objetoTax' AND table_name not like 'view%' and table_name not like '[_]%' and table_name not like '%_aux'
order by table_name

INSERT INTO [_tablas]
           ([tabla]
           ,[esMultieMpresa])
select table_name, 1
from INFORMATION_SCHEMA.TABLES
where table_name='tax_nivelTax' and table_name not like 'view%' and table_name not like '[_]%'
and table_name <> 'sysdiagrams'
order by table_name

INSERT INTO [_tablas]
           ([tabla]
           ,[esMultieMpresa])
select table_name, 1
from INFORMATION_SCHEMA.TABLES
where table_name='tax_objetoTax' and table_name not like 'view%' and table_name not like '[_]%'
and table_name <> 'sysdiagrams'
order by table_name


end


if not exists(select * FROM [_columnas]  where [tabla]='cat_sistema' and [columna]='id_sistema' )
begin

INSERT INTO [_columnas]
           ([tabla]
           ,[columna]
,[mostrarEnGrilla]
,[ordenGrilla]
           ,requerido,tipo,defecto,tamano)
select table_name, column_name,1,1, (case is_nullable when 'YES' then 0 else 1 end) as requerido,
data_type as tipo, column_default as defecto, character_maximum_length as tamano
from INFORMATION_SCHEMA.COLUMNS
where table_name='cat_sistema' AND table_name not like 'view%' and table_name not like '[_]%' and table_name not like '%_aux' and (column_name='id_sistema')
order by table_name

end