You are here: Home > Technical Articles > MS SQL Server - Create Database if does not already exist

MS Sql Server - Create Database If Does Not Exist


Sql script for creating database if it does not already exist.

IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'mysite')
BEGIN
    CREATE DATABASE mysite
END
GO

Published On: 02 Aug 2009