Need script to Remove Foreign Keys, Truncate Table, and Recreate Foreign Keys with No check
Posted on 2007-04-10
Am trying to truncate a table "tblDoucumentInfo" but get an error becuase the table contains Foreign Key Constraints. From what I have read the best way to do this, as opposed to delete and recreate the table is to remove the contraints, truncate the table, and recreate the contraints with the no check option. Doing an sp_help on the table shows the following foreign keys:
All the tables will be empty, so referential integrity should be ok. Data will later be intserted into tblDocumentInfo, and tblParty for the purpose of creating reports. It is those two tables that I need to truncate everytime I want to run reports. tblParty truncates fine.
So what would be the correct script to remove the FK contstraints, truncate the tblDocumentInfo table, and then recreate the FKs?