таблица
create table book_issue_return_details(
issue_id int primary key identity(1,1),
issued_date date,
return_date date,
for_days as datediff(day, return_date, issued_date) persisted,
penalty int,
payed int,
balance AS (penalty-payed) PERSISTED);
триггер
create trigger trforinsertpenalty
on book_issue_return_details
after insert
as
begin
declare @value int
select @value=for_days from book_issue_return_details;
update book_issue_return_details
set penalty=case
when for_days<'8' then 0
when for_days='8' then 10
when for_days='15' then 20
when for_days='30' then 30
when for_days>'30' then 100
end
end
вставить заявление
insert into book_issue_return_details(
issued_date,
return_date,
payed)
values
('16-05-2018','17-05-2018',0),
('07-05-2018','17-05-2018',0),
('01-05-2018','17-05-2018',0),
('17-05-2018','17-05-2018',0),
('01-04-2018','17-05-2018',0);
ошибка
Сообщение 241, Уровень 16, Состояние 1, Строка 1
Ошибка преобразования при преобразовании даты и / или времени из символьной строки.