Check existing databases then create

— CHECK existing databases for existence.
if exists (select * from master..sysdatabases where name = ‘dbName’ )
drop database dbName

create database dbName
on primary
(name = ‘dbName’, filename = ‘C:\data\dbName.mdf’),
log on (name = ‘dbNameLOG’, filename = ‘C:\data\dbName.ldf’)

About Spradlike

Husband and father, epilepsy survivor, avid percussionist, technology enthusiast...insisting on the road less traveled.
This entry was posted in SQL, Tools and Tricks and tagged . Bookmark the permalink.