Sql Server: delete all the rowS of all the tableS

Everything related to SQL and databases.
Post Reply
User avatar
Livear
Posts: 27
Joined: Wed Nov 29, 2017 7:29 pm

Sql Server: delete all the rowS of all the tableS

Post by Livear » Wed Feb 14, 2018 7:00 pm

I 'd like to clear the database altogether and reset the data. Exactly what's the quickest method to do that? Or, what's the command that will erase all the rows of a table (and I'll duplicate that process for all tables)? Thanks

User avatar
WallaWalla
Posts: 69
Joined: Fri Sep 08, 2017 9:25 am

Re: Sql Server: delete all the rowS of all the tableS

Post by WallaWalla » Thu Feb 15, 2018 6:33 pm

If you don't want to script and drop the tables, there are a variety of methods to do this with a loop. Here's most likely the easiest: sp_MsForEachTable 'TRUNCATE TABLE?'
Cheers!
WallaWalla

Post Reply