Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
thuyhai
Starting Member
1 Post |
Posted - 2008-01-30 : 15:12:33
|
| hi all,I have about 12 tables in the database. I want to delete all the rows in the database and bcp the data back to the tables. I don't want to delete one by one. How do I write a script to delete all the rows. Thanks |
|
|
tprupsis
Yak Posting Veteran
88 Posts |
Posted - 2008-01-30 : 16:22:05
|
| This might work for you:exec sp_MSforeachtable "DELETE FROM ? PRINT '? deleted' "If you've got foreign key relationships, you may get some errors if it tries to delete data from parent tables before the detail records are deleted.I modified the command based on what I found at http://msforums.ph/blogs/jasperjugan/archive/2005/11/10/84841.aspx |
 |
|
|
|
|
|