use AdventureWorks

--go

select * from Production.Product
select * from Sales.SalesOrderDetail
/*
go
create trigger OrderDetailNotDiscontinued
on Sales.SalesOrderDetail
instead of insert, update
as
begin
	declare @SelectProduct int
	if (exists (select * from deleted)) -- если deleted не пустая (для update)
		set @SelectProduct = (select ProductID from deleted)
	else
		set @SelectProduct = (select ProductID from inserted)

	if (exists (select * from Production.Product where ProductID = @SelectProduct and DiscontinuedDate is not null))
		Raiserror('Error',16,1)
end
*/
go
select ProductID, Name 
from Production.Product
where DiscontinuedDate is not null

update Production.Product
set DiscontinuedDate = GETDATE()
where ProductID = 680

insert Sales.SalesOrderDetail (SalesOrderID, OrderQty, ProductID, SpecialOfferID, UnitPrice, UnitPriceDiscount)
values(43660, 5,680,1,1431,0)