Check if database exists?

·

·

USE YourDatabaseName

GO

SET @dbname = ‘YourDatabaseName’

 

IF NOT EXISTS(SELECT*FROMsys.databasesWHERE name = @dbname )

 

BEGIN

–Do Something here

END



Leave a Reply

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