Właśnie stworzyliśmy Zamiast Po wyzwalania którego składnia jest podana poniżej:Jaki jest sens składnia RAISERROR()
Create trigger tgrInsteadTrigger on copytableto
Instead of Insert as
Declare @store_name varchar(30);
declare @sales int;
declare @date datetime;
select @store_name = i.store_name from inserted i
select @sales = i.sales from inserted i
select @date = i.Date from inserted i
begin
if (@sales > 1000)
begin
RAISERROR('Cannot Insert where salary > 1000',16,1); ROLLBACK;
end
else
begin
insert into copytablefrom(store_name, sales, date) values (@store_name, @sales, @date);
Print 'Instead After Trigger Executed';
end
End
W powyższej składni użyłem RAISERROR('Cannot Insert where salary > 1000',16,1)
Ale gdy piszę RAISERROR('Cannot Insert where salary > 1000')
go podaje błąd "Niepoprawna składnia w pobliżu") "" w tej samej linii.
Może ktoś proszę wyjaśnić zastosowanie (16,1) tutaj.
Składnia 'RaIsError' została wyjaśniona [tutaj] (http://msdn.microsoft.com/en-us/library/ms178592 (v = sql.100) .aspx). – HABO
Ten wyzwalacz jest zepsuty - zakłada, że istnieje * pojedynczy * wiersz w 'wstawionym', podczas gdy w rzeczywistości może być 0, 1 lub * wiele * wierszy w' wstawionym'. –