SQL Completely Empty Database SQL Completely Empty Database sql sql

SQL Completely Empty Database


Can you run the entire script within a transaction and then call a rollback if it fails?

A CREATE TABLE can be rolled back just as easily as an INSERT/UPDATE.


Sounds like a job for Drop Database:

Warning: It doesn't EMPTY the database as the question asks, but it DELETES it, so be sure you have permissions to create a new one.

-- SQL Server Syntax  DROP DATABASE [ IF EXISTS ] { database_name | database_snapshot_name } [ ,...n ] [;]


Brand new containing nothing? Drop the database and recreate it if you have permissions to do this.