Re: truncate all tables

From: Jacco Schalkwijk (NOSPAMjaccos_at_eurostop.co.uk)
Date: 04/30/04


Date: Fri, 30 Apr 2004 16:45:24 +0100

One warning to add to the above answers:

You can't truncate a table if it is referenced by a foreign key. You will
have to drop the foreign key before you can truncate the table, and recreate
it later. Disabling the foreign key constraint or emptying the referencing
table won't work

-- 
Jacco Schalkwijk
SQL Server MVP
"mikey" <anonymous@discussions.microsoft.com> wrote in message
news:69c201c42ec5$08637fb0$a601280a@phx.gbl...
> Hi does anyone know of a cmd that will truncate all the
> tables in a database of all its data while keeping table
> structures in place?
>
> Thanks for any help Mikey


Relevant Pages

  • Re: constraints in algebra instead of calculus
    ... So it ought to be possible to write any constraint from the ... I thought that one was easy, if FK is the set of 'foreign key' ... attributes and A is the 'referencing table' and using an op like D&D ... and avoiding interactions between FDs and INDs because the joint implication ...
    (comp.databases.theory)
  • Re: Primary Keys
    ... multi-field natural unique row identifier. ... Given that one table is referencing another in a (foreign key) ... addition of a unique constraint in the 'child' table. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Strange behavior with identity columns...any advice?
    ... TRUNCATE does not work on referenced tables and it ... > does not fire TRIGGERs. ... If I am using FK or TRIGGERs for some of my ... Regarding referencing tables, you cannot use DELETE either to clear a table ...
    (microsoft.public.sqlserver.programming)
  • Re: constraints in algebra instead of calculus
    ... So it ought to be possible to write any constraint from the ... I thought that one was easy, if FK is the set of 'foreign key' attributes and A is the 'referencing table' and using an op like D&D, then it's something like AB= A. ... In it they argue that a database schema should be free of circular inclusion dependencies and should only contain key-based inclusion dependencies ...
    (comp.databases.theory)
  • Re: Primary Keys
    ... that two tables' unique row identifiers would ... Given that one table is referencing another in a (foreign key) ... addition of a unique constraint in the 'child' table. ...
    (microsoft.public.access.tablesdbdesign)