Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/CloudIngenium.com/htdocs/wp-includes/functions.php on line 6114
How to delete/drop all the tables from a SQL Server database – Knowledge eXchange

How to delete/drop all the tables from a SQL Server database

I’ve recently been working on a data migration and I constantly been needing to delete all the tables in the db and start over. After doing some research I came across this hidden stored procedure in SQL Server that allows you to delete each table in the database you are connected to. Use this extremely carefully as you can’t rollback this and if you connect to the wrong db you’re going to wipe all the data.

try this

EXEC sp_MSforeachtable @command1 = “DROP TABLE ?”

You can also use the shell but I haven’t tried that

EXEC xp_cmdshell ‘SQLCMD -U -P -Q ‘EXEC sp_MSforeachtable @command1 = “DROP TABLE ?” ‘ ,no_output

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.