update t0
set Name = 'F032 - Реестр МО, осуществляющих деятельность в сфере ОМС'
from ies.T_DICTIONARY_LIST t0
join vclib.T_ENTITIES t1  on (t0.Entities = t1.EntityID)
where t1.entname = 'F032_TRMO'

update t0
set Name = 'F042 - Реестр экспертов качества МП'
from ies.T_DICTIONARY_LIST t0
join vclib.T_ENTITIES t1  on (t0.Entities = t1.EntityID)
where t1.entname = 'F042_TREKMP'

insert into ies.T_DICTIONARY_LIST(DictionaryListID, DictionaryType, Code, Entities, Name)
select newid(), (select top 1 DictionaryTypeID from ies.T_DICTIONARY_TYPE where code = '2'), SUBSTRING(t1.EntName, 0, 5), t1.EntityID, 'R006 - Классификатор причин исключения из реестра МО'
from vclib.T_ENTITIES t1
where entname = 'R006_ISKMO'

alter table [IES].[T_F042_TREKMP] ALTER COLUMN [NAME_E] int
GO
ALTER TABLE [IES].[T_F042_TREKMP] ADD CONSTRAINT [FK_T_R010_ISKEX_T_F042_TREKMP_NAME_E]
FOREIGN KEY([NAME_E]) REFERENCES [IES].[T_R010_ISKEX] ([Kod])
GO
