Friday, February 10, 2012

Clearing all data from tables in a database

Hi,
I want to clear all data from 200 tables in a database from a sql query. Some of the tables have got relationship as well. I want to clear data from there as well.
What could be the best approach? Does anyone have an idea or script from where I could do the needful?
Do let me know.
Thanks

I'm not sure of this, but what i think you might be looking for is to truncate each table.
As for the references, i do not know what happens then but i think one can temporarily disable the automatic checks for the referential integrity.
It would seem logical to be able to do so...

|||

Script your tables with primary keys, foreign keys, triggers, etc and execute the script. That would be the fastest way to get things done.

Nick

No comments:

Post a Comment