Drop a database if it exists : DROP DATABASE « Database « SQL Server / T-SQL






Drop a database if it exists

 


4> USE master
5> GO
Changed database context to 'master'.
1>
2> --Create a database
3> IF EXISTS(SELECT name FROM sys.databases
4>     WHERE name = 'ProSSEAppsCh07')
5>     DROP DATABASE ProSSEAppsCh07
6> GO
1>
2> CREATE DATABASE ProSSEAppsCh07
3> GO

 








Related examples in the same category

1.A statement that deletes a database