Check if Database Exists

Posted by Derek Dieter on SQL Server Planet See other posts from SQL Server Planet or by Derek Dieter
Published on Sun, 23 May 2010 10:06:13 +0000 Indexed on 2010/05/23 10:12 UTC
Read the original article Hit count: 413

Filed under:
In creating a database you also need to check whether or not the database already exists. In order to do so, simply use the ‘if exists’ method and select the name of the database from sysdatabases.IF NOT EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'SQLServerPlanet') CREATE DATABASE [SQLServerPlanet]The code below will drop an [...]

© SQL Server Planet or respective owner

Related posts about DBA