Disabling foreign key constraint, still can't truncate table? (SQL Server 2005)

前端 未结 4 1116
逝去的感伤
逝去的感伤 2020-12-09 08:08

I have a table called PX_Child that has a foreign key on PX_Parent. I\'d like to temporarily disable this FK constraint so that I can truncate PX_Parent. I\'m not sure how

4条回答
  •  情深已故
    2020-12-09 08:35

    SQL server will not let you truncate the table while the constraint exists, even if it's disabled. Drop the constraint and re-create it after truncating the table. Or just drop and re-create the tables, whichever is easier to do in your application.

提交回复
热议问题