-- Добавление поля "Срок выполнения обязательств по ТП" и переименования "Срока ввода в эксплуатацию" в Заявке
EXEC sp_rename 'TCApplications.InstallationDate', 'RequestedFulfilmentDate', 'COLUMN'
GO
ALTER TABLE TCSpecs add FulfilmentDate	datetime
GO
update TCWorkTypes set PrintingTemplate = REPLACE(PrintingTemplate, 'TCApplication.InstallationDate', 'TCSpec.FulfilmentDate') where PrintingTemplate like '%TCApplication.InstallationDate%'
update TCWorkTypes set InvestProgramTemplate = REPLACE(InvestProgramTemplate, 'TCApplication.InstallationDate', 'TCSpec.FulfilmentDate') where InvestProgramTemplate like '%TCApplication.InstallationDate%'
GO
update TCSpecs set FulfilmentDate = TCApplications.RequestedFulfilmentDate 
  from TCApplications
  where SpecID = TCApplicationID AND FulfilmentDate is null