Instead of dropping the constraints and adding them back, which is lots of unnecessary work, simply disable and enable them.
Put your code between these two lines:
ALTER TABLE mytable1 NOCHECK CONSTRAINT ALL
-- put your code here. Example: DELETE FROM mytable1
ALTER TABLE mytable1 CHECK CONSTRAINT ALL
Depending on your tables relationships, you may need to disable the constraints on other tables referencing your table. Example, if you need to disable the constraints on two tables:
ALTER TABLE mytable1 NOCHECK CONSTRAINT ALL
ALTER TABLE mytable2 NOCHECK CONSTRAINT ALL
-- put your code here. Example: DELETE FROM mytable1
ALTER TABLE mytable2 CHECK CONSTRAINT ALL
ALTER TABLE mytable1 CHECK CONSTRAINT ALL
If you want to disable and enable all the constraints in the database (not recommended unless you know what you're doing), you can use:
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
-- put your code here. Example: DELETE FROM mytable1
EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"