I have two tables. One is called: TFiled_for_Office with columns First Name, Last Name, Office, Party, Signatures. The other is:TMustPayFee with columns First Name, Last Name, Signatures, FeeStatus. I'm trying to create a trigger where, when inputting values in TFiled_for_Office, if the signatures entered are less than 500, the FeeStatus field will return a text value saying they must pay a filing fee. If it's more than 500, the text says they can bypass fee.
The error I'm getting is: An expression of non-boolean type specified in a context where a condition is expected, near 'then'. Maybe I'm adding extraneous syntax that shouldn't be there. Here is my query, let me know what the issue is. Thank you!
CREATE TRIGGER Filing_Fee_Eligibility ON TFiled_for_Office AFTER INSERT AS BEGIN declare @signatures int; declare @First_Name varchar(20); declare @Last_Name varchar(20); SET NOCOUNT ON; -- Insert statements for trigger here SELECT @signatures = Signatures from inserted SELECT @First_Name = @First_Name from inserted SELECT @Last_Name = @Last_Name from inserted if (select @signatures from TFiled_for_office where @signatures < '500') then insert into TMustPayFee (First_Name, Last_Name, Signatures, FeeStatus) values (@First_Name, @Last_Name, @signatures, 'Candidate must pay filing fee of $2000') else insert into TMustPayFee (First_Name, Last_Name, Signatures, FeeStatus) values (@First_Name, @Last_Name, @signatures, 'Candidate eligible to bypass filing fee') END GO