Friday, March 8, 2013

How to check whether a database exist or not in MS SQL Server

Using a simple SQL query we can check whether a database exist or not. Refer the below query.
Query:
SELECT database_id FROM sys.databases WHERE Name = 'DATABASE NAME'  

If the output is greater then 0 then the Database is exist else it's not exist

Replace the DATABASE NAME with the database name you going to check

No comments:

Post a Comment