0

In Sql server, I have 2 tables A and B table A has foreign key ID references B.Id -> I can not delete row in table B before row in table A (with same Id) and table A has trigger so that with every Id in table B, table A has least 1 row same Id , so I can not delete row in table A before row in table B

Now what should I do?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Stevie
  • 3
  • 1
  • 2

1 Answers1

1

To disable a trigger use:

DISABLE trigger trigger_name on tablename
t-clausen.dk
  • 43,517
  • 12
  • 59
  • 92
  • thank you, I tried with disable trigger in the " instead of trigger" and it worked well – Stevie Jan 30 '15 at 14:42
  • by the way. Have i to re-enable after in this trigger? – Stevie Jan 30 '15 at 14:49
  • 1
    Naturally, you should return whatever you did to how it was before. Unless it's ok to leave the trigger disabled. Also, google is your friend with this. If someone suggests disabling the trigger, you now know you can just google for "sql server disable trigger script", and the first link will provide you with an answer. It's good to ask when you need help, but it's also good to put some effort into it yourself. ;) – Kahn Jan 30 '15 at 15:05