Question : MS SQL truncate script needed

I have a MS SQL 2005 database with a 100 tables

I want to remove all rows entries in each of the tables


Do someone have a Microsoft SQL SCRIPT that i can run for this?

Answer : MS SQL truncate script needed

another way:

exec sp_MSForEachtable ' TRUNCATE TABLE ? '

however, if you have foreign keys, you cannot use truncate, you must use delete instead, and need to repeat the procedure until all tables are deleted

note: be 200% sure that you are on the correct database !!!!!!!!!!!!!!!!!!!!

note: you should write a script manually that deletes / truncated all the tables.
sql enterprise manager has a menu to script out all tables, including drop statements. that will be much shorter to do, and be clean

tip: if you need to do this regulary, you should rather have a template database, backup that template, and restore over you database...
Random Solutions  
 
programming4us programming4us