# -*- mode: snippet -*-
# name: Drop a Database
# key: sqlDropDatabase
# --
-- Drop the database '${1:DatabaseName}'
-- Connect to the 'master' database to run this snippet
USE master
GO
-- Uncomment the ALTER DATABASE statement below to set the database to SINGLE_USER mode if the drop database command fails because the database is in use.
-- ALTER DATABASE $1 SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
-- Drop the database if it exists
IF EXISTS (
  SELECT name
   FROM sys.databases
   WHERE name = N'$1'
)
DROP DATABASE $1
GO
