IF INDEXPROPERTY(Object_Id('ISZL.T_INSURED'), 'IX_T_INSURED_fio', 'IndexID') Is Not Null
BEGIN
    DROP INDEX [IX_T_INSURED_fio] ON [ISZL].[T_INSURED]
END

IF (OBJECT_ID(N'[ISZL].[INSURED_fio]') IS NOT NULL)
begin
	DROP TRIGGER [ISZL].[INSURED_fio]
end
GO

IF EXISTS (SELECT * FROM sys.columns 
           WHERE object_id = OBJECT_ID('ISZL.T_INSURED') 
           AND name = 'FIO')
BEGIN
    ALTER TABLE ISZL.T_INSURED DROP COLUMN FIO;
END

ALTER TABLE [ISZL].[T_INSURED]
ADD FIO AS 
	CAST (
		UPPER(
			REPLACE(LastName + CHAR(160) + FirstName + isnull(CHAR(160) + Patronymic, CHAR(160)), 'ё', 'е')
		) AS VARCHAR(122)
	) PERSISTED
GO

CREATE INDEX [IX_T_INSURED_fio] ON [ISZL].[T_INSURED] ([FIO]);