IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[AKUZ].[WORKER_fio]'))
DROP TRIGGER [AKUZ].[WORKER_fio]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [AKUZ].[WORKER_fio]
   ON [AKUZ].[T_WORKER]
   AFTER INSERT, UPDATE
AS 
BEGIN
    SET NOCOUNT ON
    UPDATE t
    SET t.[FIO] = t.[LastName] + ' ' + LEFT(t.[FirstName], 1) + '.' + 
        CASE 
            WHEN LEN(NULLIF(LTRIM(RTRIM(t.[FatherName])), '')) IS NOT NULL THEN LEFT(t.[FatherName], 1) + '.'
			ELSE ''
        END
    FROM [AKUZ].T_WORKER t JOIN inserted i ON t.WorkerID = i.WorkerID
END
GO