Check if a Perticular Database exist or not

This is simple sql query:

USE master
Go


IF EXISTS ( SELECT name
FROM sys.databases
WHERE name = 'MyDataBase' )
PRINT 'Exists'
ELSE
PRINT 'Does Not Exists'

 

Sandeep

a dev, an amateur photographer and a father

 

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: