Query sys.databases for database name : sys.databases « System Tables Views « SQL Server / T-SQL Tutorial






10> USE master
11> GO

13> IF EXISTS(SELECT name FROM sys.databases
14>     WHERE name = N'NewDB')
15>     DROP DATABASE NewDB
16> GO
17> 
18> CREATE DATABASE NewDB
19> GO

21> USE NewDB
22> GO








27.2.sys.databases
27.2.1.Query sys.databases
27.2.2.SELECT name, is_auto_close_on FROM sys.databases
27.2.3.Query sys.databases for database name