I am figuring out sql script that after trigger execute if two values are already existing in tables. For example.
The table shows:
╔══════════════════════════════╗
║ User_name Question_ID Answer ║
╠══════════════════════════════╣
║ Tom Q001 D ║
║ Sam Q002 F ║
╚══════════════════════════════╝
If I hope that a user can submit only one answer on a question So if I insert values ('Tom', 'Q002' 'A') it will successfully insert. But if I insert values ('Tom', 'Q001' 'A') it will execute trigger as same user tried to answer on same question.
I wrote like:
Create Trigger insert_question1
on [dbo].[Questions]
After insert
As
if
Begin
Print 'You already answered'
Rollback
End
I cannot find the condition after IF plz help me :C
See Question&Answers more detail:os