Re: Regarding table Order



Like said in the BOL:

"You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY
constraint; instead, use DELETE statement without a WHERE clause."

Therefore the only way is to delete the FK and do the truncate and
recreate the FK, or to use an insert statement instead.

HTH, jens Suessmeyer.

.



Relevant Pages

  • why drop constraints before truncate
    ... ALTER TABLE dbo.SalesFact DROP CONSTRAINT FK_SalesCustomer ... TRUNCATE TABLE dbo.SalesStage ... CONSTRAINT FK_SalesCustomer FOREIGN KEY ...
    (microsoft.public.sqlserver.programming)
  • Re: Truncate one table
    ... > The error speaks for itself. ... If a table is referenced by a foreign key ... constraint, you cannot use TRUNCATE ...
    (microsoft.public.sqlserver.programming)
  • Re: Initially deferred constraints
    ... SQL> -- Create test tables ... add constraint pk_tbl_pk ... SQL> -- Current foreign key constraint prevents this ... SQL> truncate table fk_tbl; ...
    (comp.databases.oracle.server)
  • Re: Truncate one table
    ... The error speaks for itself. ... If a table is referenced by a foreign key constraint, you cannot use TRUNCATE ...
    (microsoft.public.sqlserver.programming)
  • Re: truncate all tables
    ... You can't truncate a table if it is referenced by a foreign key. ... Disabling the foreign key constraint or emptying the referencing ... > Thanks for any help Mikey ...
    (microsoft.public.sqlserver.programming)