Tuesday, March 27, 2012

Clear all the tables of a database

Is there a simple method to clear all the tables in a db or to make a copy of the mdf file without the datas ?

I tried to use TRUNCATE TABLE but it doesn't work with foreign keys ?

Thanks.

You probably will have to write your own script for this to reflect the dependencies. As you already stated, Truncate won′t work with foreign keys and an undocumented procedure like sp_msforeachtable won′t care about the order to process.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

No comments:

Post a Comment