Search This Blog

SQL server 2005 Question With Answer

 Question :I tried to search if this had been asked before but didn't found anything so I hope It has not been 100 times before me.

Is it possible to check if a database allready exist in the SQL Server 2005? If for example I want to create a database called "Testing" I first want to check if the database exists before I create it.

Answer :
if not exists(select * from sys.databases where name = 'Testing')
    create database testing