ALTER TABLE [AKUZ].[T_SCHEDULE_FREETIME] ADD [EndTime] datetime NULL
GO
UPDATE [AKUZ].[T_SCHEDULE_FREETIME] 
SET [EndTime] = dateadd(Minute,Duration,BeginTime)
GO
ALTER TABLE [AKUZ].[T_SCHEDULE_FREETIME] ALTER COLUMN [EndTime] datetime NOT NULL
GO

-- θνδεκρ
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[AKUZ].[T_SCHEDULE_FREETIME]') AND name = N'IX_T_SCHEDULE_FREETIME_ScheduleItem')
DROP INDEX [IX_T_SCHEDULE_FREETIME_ScheduleItem] ON [AKUZ].[T_SCHEDULE_FREETIME]
GO
CREATE NONCLUSTERED INDEX [IX_T_SCHEDULE_FREETIME_ScheduleItem] ON [AKUZ].[T_SCHEDULE_FREETIME]
(
	[ScheduleItem] ASC
)
INCLUDE([ScheduleFreetimeID],[Reason],[BeginTime],[EndTime]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_SCHEDULE_FREETIME] DROP COLUMN [Duration]
GO